From a7b3fd84b34944673952250fed74cf56d730a5e6 Mon Sep 17 00:00:00 2001
From: Joe Zou <yixian.zou@gmail.com>
Date: Wed, 12 Feb 2020 21:32:40 +0800
Subject: [PATCH] fix review comment

---
 config_center/nacos/client.go   | 11 +++++------
 config_center/nacos/impl.go     |  9 +++++----
 config_center/nacos/listener.go |  3 ++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go
index 0458e1489..d87ee74dd 100644
--- a/config_center/nacos/client.go
+++ b/config_center/nacos/client.go
@@ -61,16 +61,14 @@ func WithNacosName(name string) option {
 
 // ValidateNacosClient Validate nacos client , if null then create it
 func ValidateNacosClient(container nacosClientFacade, opts ...option) error {
-	var (
-		err error
-	)
+	if container == nil {
+		return perrors.Errorf("container can not be null")
+	}
 	os := &options{}
 	for _, opt := range opts {
 		opt(os)
 	}
 
-	err = nil
-
 	url := container.GetUrl()
 
 	if container.NacosClient() == nil {
@@ -123,7 +121,7 @@ func ValidateNacosClient(container nacosClientFacade, opts ...option) error {
 		}
 	}
 
-	return perrors.WithMessagef(err, "newNacosClient(address:%+v)", url.PrimitiveURL)
+	return perrors.WithMessagef(nil, "newNacosClient(address:%+v)", url.PrimitiveURL)
 }
 
 func newNacosClient(name string, nacosAddrs []string, timeout time.Duration) (*NacosClient, error) {
@@ -147,6 +145,7 @@ func newNacosClient(name string, nacosAddrs []string, timeout time.Duration) (*N
 		split := strings.Split(nacosAddr, ":")
 		port, err := strconv.ParseUint(split[1], 10, 64)
 		if err != nil {
+			logger.Warnf("convert port , source:%s , error:%v ", split[1], err)
 			continue
 		}
 		svrconf := nacosconst.ServerConfig{
diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index d4ff3d9e9..b838e9d4c 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -159,9 +159,10 @@ func (n *nacosDynamicConfiguration) IsAvailable() bool {
 
 func (r *nacosDynamicConfiguration) closeConfigs() {
 	r.cltLock.Lock()
-	defer r.cltLock.Unlock()
-	logger.Infof("begin to close provider nacos client")
-	// Close the old client first to close the tmp node
-	r.client.Close()
+	client := r.client
 	r.client = nil
+	r.cltLock.Unlock()
+	// Close the old client first to close the tmp node
+	client.Close()
+	logger.Infof("begin to close provider nacos client")
 }
diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go
index 90af27dc0..25c586586 100644
--- a/config_center/nacos/listener.go
+++ b/config_center/nacos/listener.go
@@ -57,5 +57,6 @@ func (l *nacosDynamicConfiguration) addListener(key string, listener config_cent
 }
 
 func (l *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) {
-	// TODO not supported in current go_nacos_sdk version
+	// TODO: not supported in current go_nacos_sdk version
+	logger.Warn("not supported in current go_nacos_sdk version")
 }
-- 
GitLab