diff options
author | Steve Marion <steve.marion@sonarsource.com> | 2024-07-31 10:40:56 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-08-12 20:02:45 +0000 |
commit | 294a5e6b07d412b1bd14b0a300e1fefdc94a939b (patch) | |
tree | a1e8029ca52dac59191f95723aa54c3d40b4c732 /sonar-core/src | |
parent | 17d32c334511530ac3081f50a0e82eeaa01ea34e (diff) | |
download | sonarqube-294a5e6b07d412b1bd14b0a300e1fefdc94a939b.tar.gz sonarqube-294a5e6b07d412b1bd14b0a300e1fefdc94a939b.zip |
SONAR-22649 make UuidFactoryFast use atomic counters for parallel execution support.
Diffstat (limited to 'sonar-core/src')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java b/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java index f19744c23ca..5d5aed897aa 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java +++ b/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java @@ -20,6 +20,7 @@ package org.sonar.core.util; import java.security.SecureRandom; +import java.util.concurrent.atomic.AtomicInteger; /** * NOT thread safe @@ -29,7 +30,7 @@ import java.security.SecureRandom; public class UuidFactoryFast implements UuidFactory { private static UuidFactoryFast instance = new UuidFactoryFast(); private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - private static int sequenceNumber = new SecureRandom().nextInt(); + private AtomicInteger sequenceNumber = new AtomicInteger(new SecureRandom().nextInt()); private UuidFactoryFast() { // @@ -54,8 +55,8 @@ public class UuidFactoryFast implements UuidFactory { return instance; } - private static int getSequenceNumber() { - return sequenceNumber++; + private int getSequenceNumber() { + return sequenceNumber.getAndIncrement(); } /** Puts the lower numberOfLongBytes from l into the array, starting index pos. */ |