From 6ba5af07fd8ee97953301766196d520f5c6ebc13 Mon Sep 17 00:00:00 2001 From: Camelia Dumitru Date: Mon, 26 Feb 2024 16:11:36 +0000 Subject: [PATCH] Attempt to fix the race issue with random token generation --- .../orcid/core/oauth/OrcidRefreshTokenTokenGranterTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/orcid-core/src/test/java/org/orcid/core/oauth/OrcidRefreshTokenTokenGranterTest.java b/orcid-core/src/test/java/org/orcid/core/oauth/OrcidRefreshTokenTokenGranterTest.java index 9666752b4ae..e93edb05829 100644 --- a/orcid-core/src/test/java/org/orcid/core/oauth/OrcidRefreshTokenTokenGranterTest.java +++ b/orcid-core/src/test/java/org/orcid/core/oauth/OrcidRefreshTokenTokenGranterTest.java @@ -18,6 +18,7 @@ import javax.transaction.Transactional; import org.apache.commons.lang.StringUtils; +import org.apache.commons.math3.random.RandomDataGenerator; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -433,7 +434,8 @@ public void tryToCreateRefreshTokenWithInvalidParentTokenValueTest() { } private long getRandom() { - Random random = new Random(System.currentTimeMillis()); - return random.nextLong(); + long leftLimit = 10L; + long rightLimit = 10000000L; + return new RandomDataGenerator().nextLong(leftLimit, rightLimit); } }