This is an automated email from the ASF dual-hosted git repository.

rdhabalia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c6807a  [pulsar-broker] handle NPE when check active consumer in 
stats (#12214)
2c6807a is described below

commit 2c6807a578d5fab0711dde5531f15b924cbb3982
Author: Rajan Dhabalia <rdhaba...@apache.org>
AuthorDate: Tue Sep 28 11:37:03 2021 -0700

    [pulsar-broker] handle NPE when check active consumer in stats (#12214)
---
 .../service/persistent/PersistentDispatcherSingleActiveConsumer.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
index c4bea81..3c22242 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
@@ -558,10 +558,10 @@ public class PersistentDispatcherSingleActiveConsumer 
extends AbstractDispatcher
 
     @Override
     public boolean checkAndUnblockIfStuck() {
-        if (cursor.checkAndUpdateReadPositionChanged()) {
+        Consumer consumer = ACTIVE_CONSUMER_UPDATER.get(this);
+        if (consumer == null || cursor.checkAndUpdateReadPositionChanged()) {
             return false;
         }
-        Consumer consumer = ACTIVE_CONSUMER_UPDATER.get(this);
         int totalAvailablePermits = consumer.getAvailablePermits();
         // consider dispatch is stuck if : dispatcher has backlog, 
available-permits and there is no pending read
         if (totalAvailablePermits > 0 && !havePendingRead && 
cursor.getNumberOfEntriesInBacklog(false) > 0) {

Reply via email to