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/10 12:10:23 UTC

[GitHub] [pulsar] AnonHxy commented on a change in pull request #14641: fix: fix ArrayIndexOutOfBoundsException when concurrent

AnonHxy commented on a change in pull request #14641:
URL: https://github.com/apache/pulsar/pull/14641#discussion_r823652295



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
##########
@@ -119,17 +119,13 @@ public Consumer getNextConsumer() {
             return null;
         }
 
-        if (currentConsumerRoundRobinIndex >= consumerList.size()) {
-            currentConsumerRoundRobinIndex = 0;
-        }
-
         int currentRoundRobinConsumerPriority = consumerList.get(currentConsumerRoundRobinIndex).getPriorityLevel();
 
         // first find available-consumer on higher level unless currentIndex is not on highest level which is 0
         if (currentRoundRobinConsumerPriority != 0) {
             int higherPriorityConsumerIndex = getConsumerFromHigherPriority(currentRoundRobinConsumerPriority);
             if (higherPriorityConsumerIndex != -1) {
-                currentConsumerRoundRobinIndex = higherPriorityConsumerIndex + 1;
+                currentConsumerRoundRobinIndex = (higherPriorityConsumerIndex + 1) % consumerList.size();

Review comment:
       Should we need check  the consumer validation use `org.apache.pulsar.broker.service.AbstractDispatcherMultipleConsumers#isConsumerAvailable`?




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