Fix repeat registry, add lock for registryMethod.
@@ -51,6 +51,7 @@ type serviceListener struct {
wg sync.WaitGroup
adapterListener common2.RegistryEventListener
registryMethod map[string]*config.Method
+ mutex sync.Mutex
}
// newZkSrvListener creates a new zk service listener
@@ -166,6 +167,8 @@ func (zkl *serviceListener) handleEvent() {
},
}
apiPattern := registry.GetAPIPattern(bkConfig)
+ zkl.mutex.Lock()
+ defer zkl.mutex.Unlock()
for i := range methods {
api := registry.CreateAPIConfig(apiPattern, location, bkConfig, methods[i], mappingParams)
key := api.URLPattern + ":" + string(api.Method.HTTPVerb)
