Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ void interruptingWaitingThread_isIgnored() throws InterruptedException {
@Test
void callingInitialize_wakesUpWaitingThread() throws InterruptedException {
final AtomicBoolean isWaiting = new AtomicBoolean();
final AtomicBoolean successfulTest = new AtomicBoolean();
final AtomicLong waitTime = new AtomicLong(Long.MAX_VALUE);
Thread waitingThread = new Thread(() -> {
long start = System.currentTimeMillis();
isWaiting.set(true);
flagdProviderSyncResources.waitForInitialization(10000);
long end = System.currentTimeMillis();
long duration = end - start;
successfulTest.set(duration < MAX_TIME_TOLERANCE * 2);
waitTime.set(duration);
});
waitingThread.start();

Expand All @@ -100,7 +100,11 @@ void callingInitialize_wakesUpWaitingThread() throws InterruptedException {

waitingThread.join();

Assertions.assertTrue(successfulTest.get());
Assertions.assertTrue(
waitTime.get() < MAX_TIME_TOLERANCE * 2,
() -> "Wakeup should be almost instant, but took " + waitTime.get()
+ " ms, which is more than the max of"
+ (MAX_TIME_TOLERANCE * 2) + " ms");
}

@Timeout(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import dev.openfeature.sdk.FeatureProvider;
import dev.openfeature.sdk.FlagEvaluationDetails;
import dev.openfeature.sdk.MutableContext;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentLinkedQueue;

public class State {
public ProviderType providerType;
public Client client;
public FeatureProvider provider;
public List<Event> events = new LinkedList<>();
public ConcurrentLinkedQueue<Event> events = new ConcurrentLinkedQueue<>();
public Optional<Event> lastEvent;
public FlagSteps.Flag flag;
public MutableContext context = new MutableContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.LinkedList;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;

Expand All @@ -19,7 +18,6 @@ public class EventSteps extends AbstractSteps {

public EventSteps(State state) {
super(state);
state.events = new LinkedList<>();
}

@Given("a {} event handler")
Expand Down
Loading