diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java index 123964810c37f..9aa402d624de0 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java @@ -402,6 +402,10 @@ protected void internalCreateNonPartitionedTopic(boolean authoritative) { protected void internalUpdatePartitionedTopic(int numPartitions, boolean updateLocalTopicOnly, boolean authoritative, boolean force) { + if (numPartitions <= 0) { + throw new RestException(Status.NOT_ACCEPTABLE, "Number of partitions should be more than 0"); + } + validateTopicOwnership(topicName, authoritative); validateTopicPolicyOperation(topicName, PolicyName.PARTITION, PolicyOperation.WRITE); // Only do the validation if it's the first hop. @@ -465,9 +469,6 @@ protected void internalUpdatePartitionedTopic(int numPartitions, return; } - if (numPartitions <= 0) { - throw new RestException(Status.NOT_ACCEPTABLE, "Number of partitions should be more than 0"); - } try { tryCreatePartitionsAsync(numPartitions).get(DEFAULT_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS); updatePartitionedTopic(topicName, numPartitions, force).get(DEFAULT_OPERATION_TIMEOUT_SEC,