You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/03/26 01:55:26 UTC
[dubbo] branch 3.0 updated: Fix recover and zk notify concurrent
problem. (#7443)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new f2176cd Fix recover and zk notify concurrent problem. (#7443)
f2176cd is described below
commit f2176cd9a1d1ed34bb902ca96cd3af84ba904b47
Author: 赵延 <10...@qq.com>
AuthorDate: Fri Mar 26 09:54:43 2021 +0800
Fix recover and zk notify concurrent problem. (#7443)
* fix recover and zk notify concurrent problem.
* maybe npe fix.
---
.../org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
index 663e25d..cb97892 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
@@ -168,6 +168,9 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry {
for (String path : toCategoriesPath(url)) {
ConcurrentMap<NotifyListener, ChildListener> listeners = zkListeners.computeIfAbsent(url, k -> new ConcurrentHashMap<>());
ChildListener zkListener = listeners.computeIfAbsent(listener, k -> new RegistryChildListenerImpl(url, path, k, latch));
+ if (zkListener instanceof RegistryChildListenerImpl) {
+ ((RegistryChildListenerImpl) zkListener).setLatch(latch);
+ }
zkClient.create(path, false);
List<String> children = zkClient.addChildListener(path, zkListener);
if (children != null) {
@@ -320,6 +323,10 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry {
};
}
+ public void setLatch(CountDownLatch latch) {
+ this.latch = latch;
+ }
+
@Override
public void childChanged(String path, List<String> children) {
try {