From 9dd6f65e9de7670e25738b9d84b1ad3798c36ae6 Mon Sep 17 00:00:00 2001
From: Ming Deng <mindeng@ebay.com>
Date: Tue, 26 Nov 2019 20:12:35 +0800
Subject: [PATCH] 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 ffdb2753d..534a4b945 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 761d14006..0c19da59d 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())
-}
-- 
GitLab