diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 3a6640479c302c9e13aa979ed82d3cdaab74cf51..c25028d58f32f4028779fd6c050e60eef2bd7bd5 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 {