You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xi...@apache.org on 2022/12/05 05:03:34 UTC

[pulsar] branch branch-2.10 updated: [fix][broker] Fix SystemTopicBasedTopicPoliciesService NPE issue (#17602)

This is an automated email from the ASF dual-hosted git repository.

xiangying pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.10 by this push:
     new e281cade38d [fix][broker] Fix SystemTopicBasedTopicPoliciesService NPE issue (#17602)
e281cade38d is described below

commit e281cade38daf4d43a10d0dbf030be7a7faedbdb
Author: Jiwei Guo <te...@apache.org>
AuthorDate: Wed Sep 14 09:08:02 2022 +0800

    [fix][broker] Fix SystemTopicBasedTopicPoliciesService NPE issue (#17602)
    
    (cherry picked from commit b789b08c8c573aa12127a131ddd9b2de9dc48eec)
---
 .../pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
index 38a49df06b3..d9325235c44 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
@@ -247,7 +247,6 @@ public class SystemTopicBasedTopicPoliciesService implements TopicPoliciesServic
                 ownedBundlesCountPerNamespace.get(namespace).incrementAndGet();
                 result.complete(null);
             } else {
-                ownedBundlesCountPerNamespace.putIfAbsent(namespace, new AtomicInteger(1));
                 prepareInitPoliciesCache(namespace, result);
             }
         }
@@ -259,6 +258,7 @@ public class SystemTopicBasedTopicPoliciesService implements TopicPoliciesServic
             CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> readerCompletableFuture =
                     createSystemTopicClientWithRetry(namespace);
             readerCaches.put(namespace, readerCompletableFuture);
+            ownedBundlesCountPerNamespace.putIfAbsent(namespace, new AtomicInteger(1));
             readerCompletableFuture.thenAccept(reader -> {
                 initPolicesCache(reader, result);
                 result.thenRun(() -> readMorePolicies(reader));