Jason918 commented on a change in pull request #14038:
URL: https://github.com/apache/pulsar/pull/14038#discussion_r795033309



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/DispatchRateLimiter.java
##########
@@ -210,16 +212,16 @@ public static boolean isDispatchRateNeeded(BrokerService 
brokerService, Optional
     }
 
     public static Optional<DispatchRate> 
getTopicPolicyDispatchRate(BrokerService brokerService,
-                                                                    String 
topicName, Type type) {
+                                                                    
AbstractTopic topic, Type type) {
         Optional<DispatchRate> dispatchRate = Optional.empty();
+        String topicName = topic.getName();
         final ServiceConfiguration serviceConfiguration = 
brokerService.pulsar().getConfiguration();
         if (serviceConfiguration.isSystemTopicEnabled() && 
serviceConfiguration.isTopicLevelPoliciesEnabled()) {
             try {
                 switch (type) {
                     case TOPIC:
-                        dispatchRate = 
Optional.ofNullable(brokerService.pulsar().getTopicPoliciesService()
-                                .getTopicPolicies(TopicName.get(topicName)))
-                                .map(TopicPolicies::getDispatchRate);
+                        dispatchRate = Optional.ofNullable(
+                            isDispatchRateEnabled(topic.getDispatchRate()) ? 
topic.getDispatchRate() : null);

Review comment:
       Need to do the check before set this value in topicPolices.




-- 
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]


Reply via email to