You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/02/07 01:17:59 UTC

[GitHub] [pulsar] mattisonchao commented on a change in pull request #14134: [Issue 14105] Avoid creating any topics in `NamespaceService#checkTopicExists` during topic lookup.

mattisonchao commented on a change in pull request #14134:
URL: https://github.com/apache/pulsar/pull/14134#discussion_r800258829



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
##########
@@ -1098,9 +1099,14 @@ public ServiceUnitId getServiceUnitId(TopicName topicName) throws Exception {
         if (topic.isPersistent()) {
             return pulsar.getPulsarResources().getTopicResources().persistentTopicExists(topic);
         } else {
-            return pulsar.getBrokerService()
-                    .getTopicIfExists(topic.toString())
-                    .thenApply(optTopic -> optTopic.isPresent());
+            // only checks and don't do any topic creating and loading.
+            CompletableFuture<Optional<Topic>> topicFuture =
+                    pulsar.getBrokerService().getTopics().get(topic.toString());
+            if (topicFuture == null) {
+                return CompletableFuture.completedFuture(false);
+            } else {
+                return topicFuture.thenApply(Optional::isPresent).exceptionally(throwable -> false);

Review comment:
       Maybe we need to log in ``exceptionally``.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org