From 19418d50003c5ad4361eae12c4c72c2be9fd87fa Mon Sep 17 00:00:00 2001
From: Ming Deng <mindeng@ebay.com>
Date: Tue, 12 Nov 2019 20:41:41 +0800
Subject: [PATCH] Fix UT

---
 registry/zookeeper/listener.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go
index 3a6640479..c25028d58 100644
--- a/registry/zookeeper/listener.go
+++ b/registry/zookeeper/listener.go
@@ -109,7 +109,13 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) {
 	}
 }
 func (l *RegistryConfigurationListener) Close() {
-	l.client.Close()
+	if l.registry.IsAvailable() {
+		/**
+		 * if the registry is not available, it means that the registry has been destroy
+		 * so we don't need to call Done(), or it will cause the negative count panic for registry.wg
+		 */
+		l.registry.wg.Done()
+	}
 }
 
 func (l *RegistryConfigurationListener) valid() bool {
-- 
GitLab