You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/05/22 04:23:26 UTC

[GitHub] [rocketmq] XiaoyiPeng commented on a diff in pull request #4350: [ISSUE #4349]: Fix the potential 'IndexOutOfBoundsException' etc

XiaoyiPeng commented on code in PR #4350:
URL: https://github.com/apache/rocketmq/pull/4350#discussion_r878791161


##########
client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java:
##########
@@ -76,7 +76,9 @@ public String pickOneAtLeast() {
             if (half <= 0) {
                 return tmpList.get(0).getName();
             } else {
-                final int i = this.whichItemWorst.incrementAndGet() % half;
+                int i = this.whichItemWorst.incrementAndGet() % half;
+                if (i < 0)

Review Comment:
   Well, I didn't make it clear in the context.
   
    `i` is  return from the method `ThreadLocalIndex#incrementAndGet()`, when variable `index` in this method reach to Integer.MAX_VALUE,  `++index`  will be value of `Integer.MIN_VALUE`,  its absolute value (`Math.abs(Integer.MIN_VALUE)`) is itself, that's a negative value.



-- 
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: dev-unsubscribe@rocketmq.apache.org

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