You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tubemq.apache.org by yu...@apache.org on 2021/02/08 14:34:14 UTC

[incubator-tubemq] branch master updated: [TUBEMQ-555] short session data can only be written to a specific partition (addendum) (#423)

This is an automated email from the ASF dual-hosted git repository.

yuanbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git


The following commit(s) were added to refs/heads/master by this push:
     new 0cce8d7  [TUBEMQ-555] short session data can only be written to a specific partition (addendum) (#423)
0cce8d7 is described below

commit 0cce8d762f4148ecd138bf64553a55fc24ee565b
Author: gosonzhang <46...@qq.com>
AuthorDate: Mon Feb 8 22:34:08 2021 +0800

    [TUBEMQ-555] short session data can only be written to a specific partition (addendum) (#423)
    
    Co-authored-by: 曹显乐 <xi...@vivo.com>
    
    Co-authored-by: gosonzhang <go...@tencent.com>
    Co-authored-by: 曹显乐 <xi...@vivo.com>
---
 .../org/apache/tubemq/client/producer/RoundRobinPartitionRouter.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tubemq-client/src/main/java/org/apache/tubemq/client/producer/RoundRobinPartitionRouter.java b/tubemq-client/src/main/java/org/apache/tubemq/client/producer/RoundRobinPartitionRouter.java
index 109abdf..ec74ce5 100644
--- a/tubemq-client/src/main/java/org/apache/tubemq/client/producer/RoundRobinPartitionRouter.java
+++ b/tubemq-client/src/main/java/org/apache/tubemq/client/producer/RoundRobinPartitionRouter.java
@@ -18,8 +18,8 @@
 package org.apache.tubemq.client.producer;
 
 import java.util.List;
-import java.util.Random;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.tubemq.client.exception.TubeClientException;
 import org.apache.tubemq.corebase.Message;
@@ -41,7 +41,7 @@ public class RoundRobinPartitionRouter implements PartitionRouter {
         }
         AtomicInteger currRouterCount = partitionRouterMap.get(message.getTopic());
         if (null == currRouterCount) {
-            AtomicInteger newCounter = new AtomicInteger(new Random().nextInt());
+            AtomicInteger newCounter = new AtomicInteger(ThreadLocalRandom.current().nextInt());
             currRouterCount = partitionRouterMap.putIfAbsent(message.getTopic(), newCounter);
             if (null == currRouterCount) {
                 currRouterCount = newCounter;