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/12/28 07:10:52 UTC

[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #19086: [fix][broker] Reject create non existent persistent partitions.

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


##########
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:
   Good work! I just have a little question.
   If the `partitionIndex` is 0 and the metadata can not be found, what will happen here?



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