Skip to content

Commit

Permalink
[fix][broker] Fix NPE when set AutoTopicCreationOverride (#15653)
Browse files Browse the repository at this point in the history
(cherry picked from commit e2afcf0)
  • Loading branch information
mattisonchao committed May 25, 2022
1 parent 0813a1b commit 3b4c1a7
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -94,6 +94,8 @@
import org.apache.pulsar.common.policies.data.SubscribeRate;
import org.apache.pulsar.common.policies.data.SubscriptionAuthMode;
import org.apache.pulsar.common.policies.data.TenantOperation;
import org.apache.pulsar.common.policies.data.TopicHashPositions;
import org.apache.pulsar.common.policies.data.TopicType;
import org.apache.pulsar.common.policies.data.ValidateResult;
import org.apache.pulsar.common.policies.data.impl.AutoTopicCreationOverrideImpl;
import org.apache.pulsar.common.policies.data.impl.DispatchRateImpl;
Expand Down Expand Up @@ -810,9 +812,11 @@ protected void internalSetAutoTopicCreation(AsyncResponse asyncResponse,
"Invalid configuration for autoTopicCreationOverride. the detail is "
+ validateResult.getErrorInfo());
}
if (maxPartitions > 0 && autoTopicCreationOverride.getDefaultNumPartitions() > maxPartitions) {
throw new RestException(Status.NOT_ACCEPTABLE,
"Number of partitions should be less than or equal to " + maxPartitions);
if (Objects.equals(autoTopicCreationOverride.getTopicType(), TopicType.PARTITIONED.toString())) {
if (maxPartitions > 0 && autoTopicCreationOverride.getDefaultNumPartitions() > maxPartitions) {
throw new RestException(Status.NOT_ACCEPTABLE,
"Number of partitions should be less than or equal to " + maxPartitions);
}
}
}
// Force to read the data s.t. the watch to the cache content is setup.
Expand Down

0 comments on commit 3b4c1a7

Please sign in to comment.