diff --git a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java index 2cee1c7a627f6..03ac79fc6c9f3 100644 --- a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java +++ b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java @@ -138,23 +138,6 @@ public CompletableFuture> get(String path) { if (code == Code.OK) { future.complete(Optional.of(new GetResult(data, getStat(path1, stat)))); } else if (code == Code.NONODE) { - // Place a watch on the non-existing node, so we'll get notified - // when it gets created and we can invalidate the negative cache. - existsFromStore(path).thenAccept(exists -> { - if (exists) { - get(path).thenAccept(c -> future.complete(c)) - .exceptionally(ex -> { - future.completeExceptionally(ex); - return null; - }); - } else { - // Z-node does not exist - future.complete(Optional.empty()); - } - }).exceptionally(ex -> { - future.completeExceptionally(ex); - return null; - }); future.complete(Optional.empty()); } else { future.completeExceptionally(getException(code, path)); @@ -180,25 +163,8 @@ public CompletableFuture> getChildrenFromStore(String path) { Collections.sort(children); future.complete(children); } else if (code == Code.NONODE) { - // The node we want may not exist yet, so put a watcher on its existence - // before throwing up the exception. Its possible that the node could have - // been created after the call to getChildren, but before the call to exists(). - // If this is the case, exists will return true, and we just call getChildren - // again. - existsFromStore(path).thenAccept(exists -> { - if (exists) { - getChildrenFromStore(path).thenAccept(c -> future.complete(c)).exceptionally(ex -> { - future.completeExceptionally(ex); - return null; - }); - } else { - // Z-node does not exist - future.complete(Collections.emptyList()); - } - }).exceptionally(ex -> { - future.completeExceptionally(ex); - return null; - }); + // Z-node does not exist + future.complete(Collections.emptyList()); } else { future.completeExceptionally(getException(code, path)); }