Skip to content

Commit 6dffa1d

Browse files
authored
[improve][broker] Optimize the logic of terminating system topic (apache#17210)
1 parent beb9204 commit 6dffa1d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,11 @@ protected CompletableFuture<Void> internalRemoveMaxConsumers(boolean isGlobal) {
36753675
}
36763676

36773677
protected CompletableFuture<MessageId> internalTerminateAsync(boolean authoritative) {
3678+
if (SystemTopicNames.isSystemTopic(topicName)) {
3679+
return FutureUtil.failedFuture(new RestException(Status.METHOD_NOT_ALLOWED,
3680+
"Termination of a system topic is not allowed"));
3681+
}
3682+
36783683
CompletableFuture<Void> ret;
36793684
if (topicName.isGlobal()) {
36803685
ret = validateGlobalNamespaceOwnershipAsync(namespaceName);
@@ -3689,10 +3694,6 @@ protected CompletableFuture<MessageId> internalTerminateAsync(boolean authoritat
36893694
throw new RestException(Status.METHOD_NOT_ALLOWED,
36903695
"Termination of a partitioned topic is not allowed");
36913696
}
3692-
if (SystemTopicNames.isSystemTopic(topicName)) {
3693-
throw new RestException(Status.METHOD_NOT_ALLOWED,
3694-
"Termination of a system topic is not allowed");
3695-
}
36963697
})
36973698
.thenCompose(__ -> getTopicReferenceAsync(topicName))
36983699
.thenCompose(topic -> {

0 commit comments

Comments
 (0)