-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Branch-2.9] Fix SystemTopicBasedTopicPoliciesService NPE issue. #13840
[Branch-2.9] Fix SystemTopicBasedTopicPoliciesService NPE issue. #13840
Conversation
@@ -234,6 +233,7 @@ private void prepareInitPoliciesCache(NamespaceName namespace, CompletableFuture | |||
CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> readerCompletableFuture = | |||
creatSystemTopicClientWithRetry(namespace); | |||
readerCaches.put(namespace, readerCompletableFuture); | |||
ownedBundlesCountPerNamespace.putIfAbsent(namespace, new AtomicInteger(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move this line here, can we ensure the ownedBundlesCount
will decrease to 0 after all the bundles of the namespace are unloaded from this broker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. This is only a init operation, we need to keep readerCaches
and ownedBundlesCountPerNamespace
the data consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. My mistake.
Motivation
When SystemTopicBasedTopicPoliciesService#getTopicPolicies is invoked before SystemTopicBasedTopicPoliciesService#addOwnedNamespaceBundleAsync, it will cause NPE:
Stack trace
Modifications
ownedBundlesCountPerNamespace.putIfAbsent(namespace, new AtomicInteger(1))
in the prepareInitPoliciesCache method.Documentation
no-need-doc