RobertIndie commented on code in PR #23049:
URL: https://github.com/apache/pulsar/pull/23049#discussion_r1683929542
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -1509,6 +1515,23 @@ public CompletableFuture<List<String>>
getListOfTopics(NamespaceName namespaceNa
}
}
+ public CompletableFuture<List<String>> getListOfUserTopics(NamespaceName
namespaceName, Mode mode) {
+ String key = String.format("%s://%s", mode, namespaceName);
+ final MutableBoolean initializedByCurrentThread = new MutableBoolean();
+ CompletableFuture<List<String>> queryRes =
inProgressQueryUserTopics.computeIfAbsent(key, k -> {
+ initializedByCurrentThread.setTrue();
+ return getListOfTopics(namespaceName, mode).thenApplyAsync(list ->
{
+ return TopicList.filterSystemTopic(list);
+ }, pulsar.getExecutor());
Review Comment:
After discussing with @poorbarcode , calling the `whenComplete` in the
`computeIfAbsent` is not safe because it may remove the value while in the same
thread of `computeIfAbsent`. I'm +1 for this. Thanks @poorbarcode
--
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]