You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/01 02:47:42 UTC

[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14970: [fix][broker] The offline consumer is not removed from the consumerList

lordcheng10 commented on a change in pull request #14970:
URL: https://github.com/apache/pulsar/pull/14970#discussion_r840189904



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -163,12 +163,17 @@ protected boolean isConsumersExceededOnSubscription() {
         return isConsumersExceededOnSubscription(topic, consumerList.size());
     }
 
+    private void removeAllConsumer(Consumer consumer){
+        while(consumerList.remove(consumer)){
+        }
+    }
+    
     @Override
     public synchronized void removeConsumer(Consumer consumer) throws BrokerServiceException {
         // decrement unack-message count for removed consumer
         addUnAckedMessages(-consumer.getUnackedMessages());
         if (consumerSet.removeAll(consumer) == 1) {
-            consumerList.remove(consumer);
+            removeAllConsumer(consumer);

Review comment:
       Fixed:
   1.do a check in addConsumer;
   2.use removeIf;
   
   PTAL,thanks! @lhotari 




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org