Jason918 commented on a change in pull request #14641:
URL: https://github.com/apache/pulsar/pull/14641#discussion_r834999452
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
##########
@@ -119,26 +120,30 @@ public Consumer getNextConsumer() {
return null;
}
- if (currentConsumerRoundRobinIndex >= consumerList.size()) {
- currentConsumerRoundRobinIndex = 0;
+ // other thread will change consumerList
+ if (currentConsumerRoundRobinIndex.get() >= consumerList.size()) {
+ currentConsumerRoundRobinIndex.set(0);
}
- int currentRoundRobinConsumerPriority =
consumerList.get(currentConsumerRoundRobinIndex).getPriorityLevel();
+ int currentRoundRobinConsumerPriority =
consumerList.get(currentConsumerRoundRobinIndex.get())
Review comment:
Have a peek of the code. It seems all modification of consumerList is in
synchronized method(You need go through all the usage to verify this).
If so, this index can be calculated in a synchronized block.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]