poorbarcode commented on code in PR #19097:
URL: https://github.com/apache/pulsar/pull/19097#discussion_r1058961225
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -3157,42 +3157,38 @@ public CompletableFuture<Boolean>
isAllowAutoTopicCreationAsync(final String top
TopicName topicName = TopicName.get(topic);
return isAllowAutoTopicCreationAsync(topicName);
}
-
public CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final
TopicName topicName) {
- Optional<Policies> policies =
- pulsar.getPulsarResources().getNamespaceResources()
- .getPoliciesIfCached(topicName.getNamespaceObject());
- return isAllowAutoTopicCreationAsync(topicName, policies);
- }
-
- private CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final
TopicName topicName,
- final
Optional<Policies> policies) {
- if (policies.isPresent() && policies.get().deleted) {
- log.info("Preventing AutoTopicCreation on a namespace that is
being deleted {}",
- topicName.getNamespaceObject());
- return CompletableFuture.completedFuture(false);
- }
- //System topic can always be created automatically
- if (pulsar.getConfiguration().isSystemTopicEnabled() &&
isSystemTopic(topicName)) {
- return CompletableFuture.completedFuture(true);
- }
- final boolean allowed;
- AutoTopicCreationOverride autoTopicCreationOverride =
getAutoTopicCreationOverride(topicName, policies);
- if (autoTopicCreationOverride != null) {
- allowed = autoTopicCreationOverride.isAllowAutoTopicCreation();
- } else {
- allowed = pulsar.getConfiguration().isAllowAutoTopicCreation();
- }
-
- if (allowed && topicName.isPartitioned()) {
- // cannot re-create topic while it is being deleted
- return
pulsar.getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
- .isPartitionedTopicBeingDeletedAsync(topicName)
- .thenApply(beingDeleted -> !beingDeleted);
- } else {
- return CompletableFuture.completedFuture(allowed);
- }
-
+ return pulsar.getPulsarResources().getNamespaceResources()
+ .getPoliciesAsync(topicName.getNamespaceObject(), true)
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]