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/24 02:42:04 UTC

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

XiaoyiPeng commented on PR #4350:
URL: https://github.com/apache/rocketmq/pull/4350#issuecomment-1135337506

   @ni-ze , @HScarb , 
   
   Thanks for your review. 
   But IMO,  For code consistency, I recommend not changing this method `ThreadLocalIndex#incrementAndGet()`, because this method is used in many places.
   In most scenarios, it determine whether the result returned is positive or negative after the call, as  shown below: 
   
   ![image](https://user-images.githubusercontent.com/8653312/169936803-9ed90df7-35ff-4b8e-8c3c-225c0cee838f.png)
   
   And it we changing this method(`ThreadLocalIndex#incrementAndGet()`), The variable `index` it returned  may still be a positive number, eg: `Integer.MAX_VALUE`.  when `Math.abs(++index)` is called, we still need to judge if this value is negative, just looks like in the screenshot.
   
   Hi @panzhi33 , @RongtongJin  what's your opinion?
   
   


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