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 2021/08/06 07:30:59 UTC

[GitHub] [rocketmq] odbozhou commented on a change in pull request #3220: [ISSUE #3225]change Random to ThreadLocalRandom in broker

odbozhou commented on a change in pull request #3220:
URL: https://github.com/apache/rocketmq/pull/3220#discussion_r684013282



##########
File path: broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
##########
@@ -109,7 +109,7 @@ protected MessageExtBrokerInner buildInnerMsg(final ChannelHandlerContext ctx,
         final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) {
         int queueIdInt = requestHeader.getQueueId();
         if (queueIdInt < 0) {
-            queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();

Review comment:
       ThreadLocalRandom.current().nextInt() and random.nextInt() may produce negative numbers, if you remove Math.abs, there will be problems.




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