This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 345e58fc59 fix: CuratorWatch unwatch , childListener is null (#12742)
345e58fc59 is described below
commit 345e58fc598b38da1b51d21568e25c938385f103
Author: BigXin0109 <[email protected]>
AuthorDate: Tue Jul 18 18:46:45 2023 +0800
fix: CuratorWatch unwatch , childListener is null (#12742)
---
.../zookeeper/curator/CuratorZookeeperClient.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
index 5935286219..dc4a5d3fab 100644
---
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
+++
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
@@ -51,6 +51,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
@@ -481,13 +482,14 @@ public class CuratorZookeeperClient extends
AbstractZookeeperClient<CuratorZooke
}
if (childListener != null) {
- Runnable task = () -> {
- try {
- childListener.childChanged(path,
client.getChildren().usingWatcher(CuratorWatcherImpl.this).forPath(path));
- } catch (Exception e) {
- logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "",
"client get children error", e);
- }
- };
+ Runnable task = () -> Optional.ofNullable(childListener)
+ .ifPresent(c -> {
+ try {
+ c.childChanged(path,
client.getChildren().usingWatcher(CuratorWatcherImpl.this).forPath(path));
+ } catch (Exception e) {
+ logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "",
"client get children error", e);
+ }
+ });
initExecutorIfNecessary();
if (!closed && CURATOR_WATCHER_EXECUTOR_SERVICE != null) {
CURATOR_WATCHER_EXECUTOR_SERVICE.execute(task);