Jason918 commented on a change in pull request #13890: URL: https://github.com/apache/pulsar/pull/13890#discussion_r790124913
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java ########## @@ -3264,55 +3264,71 @@ protected MessageId internalTerminate(boolean authoritative) { } protected void internalTerminatePartitionedTopic(AsyncResponse asyncResponse, boolean authoritative) { + CompletableFuture<Void> future; if (topicName.isGlobal()) { - validateGlobalNamespaceOwnership(namespaceName); + future = validateGlobalNamespaceOwnershipAsync(namespaceName); + } else { + future = CompletableFuture.completedFuture(null); } - validateTopicOwnership(topicName, authoritative); - validateTopicOperation(topicName, TopicOperation.TERMINATE); - - Map<Integer, MessageId> messageIds = new ConcurrentHashMap<>(); - PartitionedTopicMetadata partitionMetadata = getPartitionedTopicMetadata(topicName, authoritative, false); - - if (partitionMetadata.partitions == 0) { - throw new RestException(Status.METHOD_NOT_ALLOWED, "Termination of a non-partitioned topic is " - + "not allowed using partitioned-terminate, please use terminate commands."); - } - if (partitionMetadata.partitions > 0) { - final List<CompletableFuture<MessageId>> futures = Lists.newArrayList(); + future.thenAccept(__ -> validateTopicOperationAsync(topicName, TopicOperation.TERMINATE) + .thenCompose(unused -> getPartitionedTopicMetadataAsync(topicName, authoritative, false)) + .thenAccept(partitionMetadata -> { + if (partitionMetadata.partitions == 0) { + String msg = "Termination of a non-partitioned topic is not allowed using partitioned-terminate" + + ", please use terminate commands"; + log.error("[{}] [{}] {}", clientAppId(), topicName, msg); + asyncResponse.resume(new RestException(Status.METHOD_NOT_ALLOWED, msg)); + return; + } + if (partitionMetadata.partitions > 0) { + validateTopicOwnershipAsync(topicName, authoritative).thenAccept(unused -> { Review comment: 1. exception of `validateTopicOwnershipAsync` seems not handled. 2. I think we don't need to add `validateTopicOwnershipAsync` 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-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org