Optimize update partition logic
@@ -402,6 +402,10 @@ public class PersistentTopicsBase extends AdminResource {
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 @@ public class PersistentTopicsBase extends AdminResource {
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,
