lhotari commented on code in PR #24225: URL: https://github.com/apache/pulsar/pull/24225#discussion_r2087237846
########## pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java: ########## @@ -725,26 +766,16 @@ protected Map<String, CompletableFuture<Void>> internalCreatePartitionedTopicToR /** * Check the exists topics contains the given topic. - * Since there are topic partitions and non-partitioned topics in Pulsar, must ensure both partitions - * and non-partitioned topics are not duplicated. So, if compare with a partition name, we should compare - * to the partitioned name of this partition. + * Since there are topic partitions and non-partitioned topics in Pulsar. This check ensures that + * there is no duplication between them. Partition *instances* (e.g., topic-partition-0) + * are not considered individually — only the base partitioned topic name is checked. + * + * <p>Note: Be sure to recycle the {@link TopicExistsInfo} after it is no longer needed.</p> * * @param topicName given topic name */ - protected CompletableFuture<Boolean> checkTopicExistsAsync(TopicName topicName) { - return pulsar().getNamespaceService().getListOfTopics(topicName.getNamespaceObject(), - CommandGetTopicsOfNamespace.Mode.ALL) - .thenCompose(topics -> { - boolean exists = false; - for (String topic : topics) { - if (topicName.getPartitionedTopicName().equals( - TopicName.get(topic).getPartitionedTopicName())) { - exists = true; - break; - } - } - return CompletableFuture.completedFuture(exists); - }); + protected CompletableFuture<TopicExistsInfo> checkTopicExistsAsync(TopicName topicName) { + return pulsar().getNamespaceService().checkTopicExists(topicName); Review Comment: this `checkTopicExists` is deprecated in NamespaceService. There's a method called `checkTopicExistsAsync` which I guess is intended to be used instead. -- 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-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org