Wushiyii opened a new pull request, #4447:
URL: https://github.com/apache/rocketmq/pull/4447

   ## What is the purpose of the change
   See https://github.com/apache/rocketmq/issues/4349
   
   In ThreadLocalIndex.java, when the random index increase to 
Integer.MAX_VALUE(2147483647), the next increment value is 
Integer.MIN_VALUE(-2147483648). And the code `Math.abs(index)` will also return 
the same negatice value Integer.MIN_VALUE(-2147483648)
   
   ```java
       /**
        * Returns the absolute value of an {@code int} value.
        * If the argument is not negative, the argument is returned.
        * If the argument is negative, the negation of the argument is returned.
        *
        * <p>Note that if the argument is equal to the value of
        * {@link Integer#MIN_VALUE}, the most negative representable
        * {@code int} value, the result is that same value, which is
        * negative.
        *
        * @param   a   the argument whose absolute value is to be determined
        * @return  the absolute value of the argument.
        */
       public static int abs(int a) {
           return (a < 0) ? -a : a;
       }
   ```
   
   ## Brief changelog
   [ISSUE #4349] Fix negative ThreadLocalIndex
   


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

Reply via email to