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/03/31 16:53:24 UTC

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

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



##########
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:
       The `removeAllConsumer` doesn't look great. I wonder if using `.removeIf` would be better:
   ```suggestion
               consumerList.removeIf(consumer::equals);
   ```




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