coderzc commented on code in PR #21231:
URL: https://github.com/apache/pulsar/pull/21231#discussion_r1334036061
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -219,12 +223,12 @@ public TopicPolicies getTopicPolicies(TopicName topicName,
boolean isGlobal) throws
TopicPoliciesCacheNotInitException {
if (!policyCacheInitMap.containsKey(topicName.getNamespaceObject())) {
NamespaceName namespace = topicName.getNamespaceObject();
- prepareInitPoliciesCache(namespace, new CompletableFuture<>());
+ prepareInitPoliciesCacheAsync(namespace);
}
MutablePair<TopicPoliciesCacheNotInitException, TopicPolicies> result
= new MutablePair<>();
policyCacheInitMap.compute(topicName.getNamespaceObject(), (k,
initialized) -> {
- if (initialized == null || !initialized) {
+ if (initialized == null || !initialized.isDone()) {
Review Comment:
Also need to handle `initialized.isCompletedExceptionally()`.
If `initialized.isCompletedExceptionally()` we need to remove `initialized`
from policyCacheInitMap.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -381,8 +422,7 @@ private void
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
if (log.isDebugEnabled()) {
log.debug("[{}] Reach the end of the system topic.",
reader.getSystemTopic().getTopicName());
}
- policyCacheInitMap.computeIfPresent(
-
reader.getSystemTopic().getTopicName().getNamespaceObject(), (k, v) -> true);
Review Comment:
It doesn't seem to remove this, only when the execution reaches this line
does it mean that init is completed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]