This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 1178d9a  Fix: do not copy sync.Map
1178d9a is described below

commit 1178d9a142bda19c04f49a9f584c96f68540a029
Author: AlexStocks <[email protected]>
AuthorDate: Tue Jul 2 18:21:34 2019 +0800

    Fix: do not copy sync.Map
---
 common/config/environment.go   | 17 +++++++++++++----
 config/registry_config.go      |  4 ++--
 remoting/zookeeper/listener.go |  6 +++---
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/common/config/environment.go b/common/config/environment.go
index 998f0be..8709d69 100644
--- a/common/config/environment.go
+++ b/common/config/environment.go
@@ -63,32 +63,40 @@ func (env *Environment) UpdateExternalConfigMap(externalMap 
map[string]string) {
 func (env *Environment) Configuration() *list.List {
        list := list.New()
        memConf := newInmemoryConfiguration()
-       memConf.setProperties(env.externalConfigMap)
+       memConf.setProperties(&(env.externalConfigMap))
        list.PushBack(memConf)
        return list
 }
 
 type InmemoryConfiguration struct {
-       store sync.Map
+       store *sync.Map
 }
 
 func newInmemoryConfiguration() *InmemoryConfiguration {
        return &InmemoryConfiguration{}
 }
-func (conf *InmemoryConfiguration) setProperties(p sync.Map) {
+func (conf *InmemoryConfiguration) setProperties(p *sync.Map) {
        conf.store = p
 }
 
 func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) {
+       if conf.store == nil {
+               return false, ""
+       }
+
        v, ok := conf.store.Load(key)
        if ok {
                return true, v.(string)
        }
-       return false, ""
 
+       return false, ""
 }
 
 func (conf *InmemoryConfiguration) GetSubProperty(subKey string) 
map[string]struct{} {
+       if conf.store == nil {
+               return nil
+       }
+
        properties := make(map[string]struct{})
        conf.store.Range(func(key, value interface{}) bool {
                if idx := strings.Index(key.(string), subKey); idx >= 0 {
@@ -100,5 +108,6 @@ func (conf *InmemoryConfiguration) GetSubProperty(subKey 
string) map[string]stru
                }
                return true
        })
+
        return properties
 }
diff --git a/config/registry_config.go b/config/registry_config.go
index 0c6b326..1a926b4 100644
--- a/config/registry_config.go
+++ b/config/registry_config.go
@@ -37,8 +37,8 @@ type RegistryConfig struct {
        Group      string `yaml:"group" json:"group,omitempty" property:"group"`
        //for registry
        Address  string `yaml:"address" json:"address,omitempty" 
property:"address"`
-       Username string `yaml:"username" json:"address,omitempty" 
property:"username"`
-       Password string `yaml:"password" json:"address,omitempty"  
property:"password"`
+       Username string `yaml:"username" json:"username,omitempty" 
property:"username"`
+       Password string `yaml:"password" json:"password,omitempty"  
property:"password"`
 }
 
 func (*RegistryConfig) Prefix() string {
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index af668a1..5b9e0a8 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -129,14 +129,14 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath 
string, children []string, li
                        continue
                }
                // listen l service node
-               go func(node string) {
+               go func(node, childNode string) {
                        logger.Infof("delete zkNode{%s}", node)
                        if l.ListenServiceNodeEvent(node, listener) {
-                               logger.Infof("delete content{%s}", n)
+                               logger.Infof("delete content{%s}", childNode)
                                listener.DataChange(remoting.Event{Path: 
zkPath, Action: remoting.EventTypeDel})
                        }
                        logger.Warnf("listenSelf(zk path{%s}) goroutine exit 
now", zkPath)
-               }(newNode)
+               }(newNode, n)
        }
 
        // old node was deleted

Reply via email to