Skip to content

Commit

Permalink
[ISSUE apache#8118] Remove redundant mod in client (apache#8119)
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-ton authored May 14, 2024
1 parent d943456 commit 502e2d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public List<MessageQueue> allocate(String consumerGroup, String currentCID, List
int startIndex = (mod > 0 && index < mod) ? index * averageSize : index * averageSize + mod;
int range = Math.min(averageSize, mqAll.size() - startIndex);
for (int i = 0; i < range; i++) {
result.add(mqAll.get((startIndex + i) % mqAll.size()));
result.add(mqAll.get(startIndex + i));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,7 @@ public String findBrokerAddrByTopic(final String topic) {
if (topicRouteData != null) {
List<BrokerData> brokers = topicRouteData.getBrokerDatas();
if (!brokers.isEmpty()) {
int index = random.nextInt(brokers.size());
BrokerData bd = brokers.get(index % brokers.size());
BrokerData bd = brokers.get(random.nextInt(brokers.size()));
return bd.selectBrokerAddr();
}
}
Expand Down

0 comments on commit 502e2d7

Please sign in to comment.