You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by fa...@apache.org on 2019/11/26 12:53:22 UTC

[dubbo-go] branch master updated: It seems that we can not change the registryProtocol to be singleton. If we do tthat, the listen, speciall zk registry listener doesn't work.

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

fangyc 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 6d939d6  It seems that we can not change the registryProtocol to be singleton. If we do tthat, the listen, speciall zk registry listener doesn't work.
     new d77b772  Merge pull request #265 from flycash/bug/reverseRegistryProtocol
6d939d6 is described below

commit 6d939d6e6c48b2fcfd7eb8113976fd0a8e5f7849
Author: Ming Deng <mi...@ebay.com>
AuthorDate: Tue Nov 26 20:12:35 2019 +0800

    It seems that we can not change the registryProtocol to be singleton. If we do tthat, the listen, speciall zk registry listener doesn't work.
---
 registry/protocol/protocol.go      | 6 +++---
 registry/protocol/protocol_test.go | 5 -----
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go
index ffdb275..534a4b9 100644
--- a/registry/protocol/protocol.go
+++ b/registry/protocol/protocol.go
@@ -338,10 +338,10 @@ func setProviderUrl(regURL *common.URL, providerURL *common.URL) {
 }
 
 func GetProtocol() protocol.Protocol {
-	if regProtocol == nil {
-		regProtocol = newRegistryProtocol()
+	if regProtocol != nil {
+		return regProtocol
 	}
-	return regProtocol
+	return newRegistryProtocol()
 }
 
 type wrappedInvoker struct {
diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go
index 761d140..0c19da5 100644
--- a/registry/protocol/protocol_test.go
+++ b/registry/protocol/protocol_test.go
@@ -291,8 +291,3 @@ func TestExportWithApplicationConfig(t *testing.T) {
 	v2, _ := regProtocol.bounds.Load(getCacheKey(newUrl))
 	assert.NotNil(t, v2)
 }
-
-func TestGetProtocol(t *testing.T) {
-	singleton := GetProtocol()
-	assert.True(t, singleton == GetProtocol())
-}