315157973 commented on code in PR #18235: URL: https://github.com/apache/pulsar/pull/18235#discussion_r1007916716
########## pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java: ########## @@ -248,6 +245,14 @@ public CompletableFuture<Boolean> existsAsync(String path, Watcher watcher) { if (rc == Code.OK.intValue()) { future.complete(true); } else if (rc == Code.NONODE.intValue()) { + // remove watcher if node does not exist + zk.removeAllWatches(path, Watcher.WatcherType.Any, true, + (rc0, path0, ctx0) -> { + Code code0 = Code.get(rc0); + if (code0 != Code.OK && code0 != Code.NOWATCHER) { + log.warn("Remove watcher failed. rc: {}, path: {}", code0, path); + } + }, null); Review Comment: Can this repetitive code abstract a method? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org