Skip to content

Commit 13d01ac

Browse files
committed
[TEST] Do not call RandomizedTest.scaledRandomIntBetween from multiple threads
KeyedLockTests calls RandomizedTest.scaledRandomIntBetween from multiple threads which uses RandomizedTest.isNightly() whereas that method is not concurrency-safe (see implementation of GroupEvaluator.isGroupEnabled)
1 parent d12793a commit 13d01ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/test/java/org/elasticsearch/common/util/concurrent/KeyedLockTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static class AcquireAndReleaseThread extends Thread {
7474
String[] names;
7575
ConcurrentHashMap<String, Integer> counter;
7676
ConcurrentHashMap<String, AtomicInteger> safeCounter;
77+
final int numRuns = scaledRandomIntBetween(5000, 50000);
7778

7879
public AcquireAndReleaseThread(CountDownLatch startLatch, KeyedLock<String> connectionLock, String[] names,
7980
ConcurrentHashMap<String, Integer> counter, ConcurrentHashMap<String, AtomicInteger> safeCounter) {
@@ -91,7 +92,6 @@ public void run() {
9192
} catch (InterruptedException e) {
9293
throw new RuntimeException(e);
9394
}
94-
int numRuns = scaledRandomIntBetween(5000, 50000);
9595
for (int i = 0; i < numRuns; i++) {
9696
String curName = names[randomInt(names.length - 1)];
9797
assert connectionLock.isHeldByCurrentThread(curName) == false;

0 commit comments

Comments
 (0)