Skip to content

Commit 7aab561

Browse files
Fix ProviderTest.itCanDoAValueEvaluation race condition on Java 11
Add Awaitility.await() guard before asserting on getObjectValue result, matching the pattern used by the other evaluation tests (boolean, string, double). Without this, setProvider (non-blocking) may not have completed by the time getObjectValue is called, returning the default Value() whose asStructure() is null — causing a NullPointerException on Java 11. Co-Authored-By: rlamb@launchdarkly.com <kingdewman@gmail.com>
1 parent 295d286 commit 7aab561

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ public void itCanDoAValueEvaluation() {
128128
.thenReturn(evaluationDetail);
129129

130130
OpenFeatureAPI.getInstance().setProvider(ldProvider);
131+
132+
Awaitility.await().forever().until(() -> {
133+
Value val = OpenFeatureAPI.getInstance().getClient()
134+
.getObjectValue("the-key", new Value(), evaluationContext);
135+
return val != null && val.asStructure() != null;
136+
});
137+
131138
Value ofValue = OpenFeatureAPI
132139
.getInstance()
133140
.getClient()

0 commit comments

Comments
 (0)