You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/03/25 16:53:47 UTC

[GitHub] [skywalking] muse-dev[bot] commented on a change in pull request #6623: Timestamp in GlobalIdGenerator is implemented using ThreadLocalRandom

muse-dev[bot] commented on a change in pull request #6623:
URL: https://github.com/apache/skywalking/pull/6623#discussion_r601670465



##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java
##########
@@ -74,11 +74,8 @@ private long timestamp() {
 
             if (currentTimeMillis < lastTimestamp) {
                 // Just for considering time-shift-back by Ops or OS. @hanahmily 's suggestion.
-                if (random == null) {
-                    random = new Random();
-                }
                 if (runRandomTimestamp != currentTimeMillis) {
-                    lastRandomValue = random.nextInt();
+                    lastRandomValue = ThreadLocalRandom.current().nextInt();

Review comment:
       *PREDICTABLE_RANDOM:*  This random generator (java.util.concurrent.ThreadLocalRandom) is predictable [(details)](https://find-sec-bugs.github.io/bugs.htm#PREDICTABLE_RANDOM)
   (at-me [in a reply](https://docs.muse.dev/docs/talk-to-muse/) with `help` or `ignore`)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org