Skip to content

Commit dec411a

Browse files
committed
Merge branch 'apache-3.1' into 3.1.11-release
2 parents 99d413f + c45ce19 commit dec411a

File tree

1 file changed

+12
-1
lines changed
  • dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange

1 file changed

+12
-1
lines changed

dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.utils.StringUtils;
2020

21+
import java.security.SecureRandom;
2122
import java.util.concurrent.ThreadLocalRandom;
2223
import java.util.concurrent.atomic.AtomicLong;
2324

@@ -28,7 +29,7 @@
2829
*/
2930
public class Request {
3031

31-
private static final AtomicLong INVOKE_ID = new AtomicLong(ThreadLocalRandom.current().nextLong());
32+
private static final AtomicLong INVOKE_ID;
3233

3334
private final long mId;
3435

@@ -50,6 +51,16 @@ public Request(long id) {
5051
mId = id;
5152
}
5253

54+
static {
55+
long startID = ThreadLocalRandom.current().nextLong();
56+
try {
57+
SecureRandom rand = new SecureRandom(SecureRandom.getSeed(20));
58+
startID = rand.nextLong();
59+
} catch (Throwable ignore) {
60+
}
61+
INVOKE_ID = new AtomicLong(startID);
62+
}
63+
5364
private static long newId() {
5465
// getAndIncrement() When it grows to MAX_VALUE, it will grow to MIN_VALUE, and the negative can be used as ID
5566
return INVOKE_ID.getAndIncrement();

0 commit comments

Comments
 (0)