You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2023/07/14 03:00:06 UTC
[dubbo] branch 3.2 updated: Support skip use secure random id (#12724)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 976ffda33b Support skip use secure random id (#12724)
976ffda33b is described below
commit 976ffda33bfb8d29c22f47119a4163204bcf974e
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Fri Jul 14 11:00:01 2023 +0800
Support skip use secure random id (#12724)
---
.../src/main/java/org/apache/dubbo/remoting/Constants.java | 1 +
.../main/java/org/apache/dubbo/remoting/exchange/Request.java | 11 +++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java
index ece265989d..51b42ec185 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java
@@ -173,4 +173,5 @@ public interface Constants {
String CONTENT_LENGTH_KEY = "content-length";
+ String USE_SECURE_RANDOM_ID = "dubbo.application.use-secure-random-request-id";
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
index d212e51bbd..67df1e73ea 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
@@ -23,6 +23,7 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
import static org.apache.dubbo.common.constants.CommonConstants.HEARTBEAT_EVENT;
+import static org.apache.dubbo.remoting.Constants.USE_SECURE_RANDOM_ID;
/**
* Request.
@@ -55,10 +56,12 @@ public class Request {
static {
long startID = ThreadLocalRandom.current().nextLong();
- try {
- SecureRandom rand = new SecureRandom(SecureRandom.getSeed(20));
- startID = rand.nextLong();
- } catch (Throwable ignore) {
+ if (Boolean.parseBoolean(System.getProperty(USE_SECURE_RANDOM_ID, "true"))) {
+ try {
+ SecureRandom rand = new SecureRandom(SecureRandom.getSeed(20));
+ startID = rand.nextLong();
+ } catch (Throwable ignore) {
+ }
}
INVOKE_ID = new AtomicLong(startID);
}