Skip to content

Commit

Permalink
Optimize update partition logic (apache#13188)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordcheng10 authored Dec 14, 2021
1 parent 01c5f89 commit 6df01ba
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6df01ba

Please sign in to comment.