merlimat commented on a change in pull request #5408: [pulsar-broker] Fix bug 
that namespace policies does not take effect due to NPE
URL: https://github.com/apache/pulsar/pull/5408#discussion_r336174034
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
 ##########
 @@ -1372,7 +1372,7 @@ private void updateSubscriptionMessageDispatchRate() {
             forEachTopic(topic -> {
                 topic.getSubscriptions().forEach((subName, 
persistentSubscription) -> {
                     Dispatcher dispatcher = 
persistentSubscription.getDispatcher();
-                    if (dispatcher.getRateLimiter().isPresent()) {
+                    if (dispatcher != null && 
dispatcher.getRateLimiter().isPresent()) {
                         dispatcher.getRateLimiter().get().updateDispatchRate();
                     }
 
 Review comment:
   To make it even more sure, can we do like: 
   
   ```java
   Dispatcher dispatcher = persistentSubscription.getDispatcher();
   if (dispatcher != null) {
       
dispatcher.getRateLimiter().ifPresent(DispatchRateLimiter::updateDispatchRate);
   }
   ```

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


With regards,
Apache Git Services

Reply via email to