Skip to content

Commit 694526e

Browse files
committed
Flaky build due to a possible race condition #1449
Signed-off-by: christian.lutnik <[email protected]>
1 parent 9e2cbd8 commit 694526e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/dev/openfeature/sdk/Awaitable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.openfeature.sdk;
22

33
/**
4-
* A class to help with synchronization
4+
* A class to help with synchronization.
55
*/
66
public class Awaitable {
77
public static final Awaitable FINISHED = new Awaitable(true);
@@ -17,7 +17,7 @@ private Awaitable(boolean isDone) {
1717
/**
1818
* Lets the calling thread wait until some other thread calls {@link Awaitable#wakeup()}. If
1919
* {@link Awaitable#wakeup()} has been called before the current thread invokes this method, it will return
20-
* immediately
20+
* immediately.
2121
*/
2222
public void await() {
2323
if (isDone) {

src/test/java/dev/openfeature/sdk/AwaitableTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package dev.openfeature.sdk;
22

3+
import static org.awaitility.Awaitility.await;
34
import static org.junit.jupiter.api.Assertions.assertTrue;
45
import static org.junit.jupiter.api.Assertions.fail;
56

7+
import java.util.concurrent.TimeUnit;
68
import java.util.concurrent.atomic.AtomicBoolean;
79
import java.util.concurrent.atomic.AtomicInteger;
810
import org.junit.jupiter.api.Test;
@@ -62,9 +64,7 @@ void callingWakeUpWakesUpAllWaitingThreads() throws InterruptedException {
6264
threads[i].start();
6365
}
6466

65-
while (isRunning.get() < numThreads) {
66-
Thread.sleep(1);
67-
}
67+
await().atMost(1, TimeUnit.SECONDS).until(() -> isRunning.get() == numThreads);
6868

6969
awaitable.wakeup();
7070

0 commit comments

Comments
 (0)