eolivelli commented on a change in pull request #10683:
URL: https://github.com/apache/pulsar/pull/10683#discussion_r637502011
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -2555,36 +2555,30 @@ private boolean isSystemTopic(String topic) {
}
/**
- * Get {@link TopicPolicies} for this topic.
+ * Get {@link TopicPolicies} for the parameterized topic.
* @param topicName
* @return TopicPolicies is exist else return null.
*/
public TopicPolicies getTopicPolicies(TopicName topicName) {
+ if (!pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
+ return null;
+ }
TopicName cloneTopicName = topicName;
if (topicName.isPartitioned()) {
cloneTopicName =
TopicName.get(topicName.getPartitionedTopicName());
}
try {
- checkTopicLevelPolicyEnable();
return
pulsar.getTopicPoliciesService().getTopicPolicies(cloneTopicName);
} catch (BrokerServiceException.TopicPoliciesCacheNotInitException e) {
log.debug("Topic {} policies have not been initialized yet.",
topicName.getPartitionedTopicName());
return null;
- } catch (RestException | NullPointerException e) {
+ } catch (NullPointerException e) {
Review comment:
Get we get rid of this `catch NPE`.
It is really a code smell.
I see it was only moved from another point, but it is a good time to fix
things when we put our hands on.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]