mattisonchao commented on code in PR #19086:
URL: https://github.com/apache/pulsar/pull/19086#discussion_r1058346292


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1016,27 +1016,27 @@ public CompletableFuture<Optional<Topic>> 
getTopic(final TopicName topicName, bo
                 }
             }
             final boolean isPersistentTopic = 
topicName.getDomain().equals(TopicDomain.persistent);
-            if (isPersistentTopic) {
-                return topics.computeIfAbsent(topicName.toString(), (k) -> {
-                    return this.loadOrCreatePersistentTopic(k, 
createIfMissing, properties);
-                });
-            } else {
-                return topics.computeIfAbsent(topicName.toString(), (name) -> {
+            return topics.computeIfAbsent(topicName.toString(), (name) -> {
+                    // partitioned topic
                     if (topicName.isPartitioned()) {
                         final TopicName partitionedTopicName = 
TopicName.get(topicName.getPartitionedTopicName());
-                        return 
this.fetchPartitionedTopicMetadataAsync(partitionedTopicName).thenCompose((metadata)
 -> {
+                        return 
fetchPartitionedTopicMetadataAsync(partitionedTopicName).thenCompose((metadata) 
-> {
                             if (topicName.getPartitionIndex() < 
metadata.partitions) {
-                                return createNonPersistentTopic(name);
+                                return isPersistentTopic ?
+                                        loadOrCreatePersistentTopic(name, 
createIfMissing, properties) :

Review Comment:
   >If the partitionIndex is 0 and the metadata can not be found, what will 
happen here?
   
   I think we should reject the topic creation if it includes `partition` 
keywords but it didn't have partitioned metadata. 
   WDYT? 
   /cc @codelipenghui @eolivelli @Technoboy- 



-- 
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]

Reply via email to