Skip to content

Commit f0650d3

Browse files
Replace Awaitility.await().forever() with 10-second timeout in ProviderTest
Address review feedback: all Awaitility waits now use atMost(10s) instead of forever() to prevent hanging the build if a bug prevents provider initialization. This applies to the existing boolean/string/double tests as well as the new value evaluation test. Co-Authored-By: rlamb@launchdarkly.com <kingdewman@gmail.com>
1 parent 7aab561 commit f0650d3

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/test/java/com/launchdarkly/openfeature/serverprovider/ProviderTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212

1313
import org.awaitility.Awaitility;
1414

15+
import java.time.Duration;
16+
1517
import static org.junit.jupiter.api.Assertions.*;
1618

19+
/**
20+
* Timeout for Awaitility waits. Provider initialization should complete quickly
21+
* since these tests use a mock client, but we need a non-infinite bound to avoid
22+
* hanging the build if a bug prevents initialization.
23+
*/
24+
1725
public class ProviderTest {
1826
LDClientInterface mockedLdClient = mock(LDClientInterface.class);
1927

@@ -38,7 +46,7 @@ public void itCanDoABooleanEvaluation() {
3846

3947
OpenFeatureAPI.getInstance().setProvider(ldProvider);
4048

41-
Awaitility.await().forever().until(() -> OpenFeatureAPI
49+
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> OpenFeatureAPI
4250
.getInstance()
4351
.getClient()
4452
.getBooleanValue("the-key", false, evaluationContext));
@@ -68,7 +76,7 @@ public void itCanDoAStringEvaluation() {
6876

6977
OpenFeatureAPI.getInstance().setProvider(ldProvider);
7078

71-
Awaitility.await().forever().until(() -> OpenFeatureAPI
79+
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> OpenFeatureAPI
7280
.getInstance()
7381
.getClient()
7482
.getStringValue("the-key", "default", evaluationContext).equals("evaluated"));
@@ -97,7 +105,7 @@ public void itCanDoADoubleEvaluation() {
97105

98106
OpenFeatureAPI.getInstance().setProvider(ldProvider);
99107

100-
Awaitility.await().forever().until(() -> OpenFeatureAPI
108+
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> OpenFeatureAPI
101109
.getInstance()
102110
.getClient()
103111
.getDoubleValue("the-key", 0.0, evaluationContext) != 0.0);
@@ -129,7 +137,7 @@ public void itCanDoAValueEvaluation() {
129137

130138
OpenFeatureAPI.getInstance().setProvider(ldProvider);
131139

132-
Awaitility.await().forever().until(() -> {
140+
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> {
133141
Value val = OpenFeatureAPI.getInstance().getClient()
134142
.getObjectValue("the-key", new Value(), evaluationContext);
135143
return val != null && val.asStructure() != null;

0 commit comments

Comments
 (0)