diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java index c27575c81a842..6cf73593137e1 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java @@ -210,7 +210,13 @@ public CompletableFuture checkOwnership(NamespaceBundle bundle) { return CompletableFuture.completedFuture(true); } String bundlePath = ServiceUnitUtils.path(bundle); - return resolveOwnership(bundlePath).thenApply(Optional::isPresent); + return resolveOwnership(bundlePath).thenApply(optionalOwnedDataWithStat -> { + if (!optionalOwnedDataWithStat.isPresent()) { + return false; + } + Stat stat = optionalOwnedDataWithStat.get().getValue(); + return stat.getEphemeralOwner() == localZkCache.getZooKeeper().getSessionId(); + }); } /**