Support skip use secure random id (#12724)
This commit is contained in:
parent
65491fda07
commit
976ffda33b
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue