From e2a42d554d2cac5c0bea1520b6c5f90d72ef7156 Mon Sep 17 00:00:00 2001 From: datadog-bits <263423550+datadog-bits@users.noreply.github.com> Date: Sun, 6 Dec 2026 09:46:56 +0000 Subject: [PATCH] Fix flaky DDEvaluatorTest shutdown-during-initialization test The Remote Configuration subscription fires inside the evaluator's synchronized initialization, before it assigns its runtime, so the test could read a null runtime. Wait for the evaluator to release its monitor before comparing runtimes. Co-Authored-By: Claude Opus 5.5 (1M context) Co-authored-by: colin-higgins <1801443+colin-higgins@users.noreply.github.com> --- .../test/java/com/datadog/openfeature/DDEvaluatorTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dd-openfeature/src/test/java/com/datadog/openfeature/DDEvaluatorTest.java b/dd-openfeature/src/test/java/com/datadog/openfeature/DDEvaluatorTest.java index 202824b8f4c..59187444de6 100644 --- a/dd-openfeature/src/test/java/com/datadog/openfeature/DDEvaluatorTest.java +++ b/dd-openfeature/src/test/java/com/datadog/openfeature/DDEvaluatorTest.java @@ -213,6 +213,10 @@ public void testShutdownWhileInitializationWaitsForConfiguration() throws Except executor.submit(() -> evaluator.initialize(60, SECONDS, null)); try { assertTrue(subscribed.await(5, SECONDS)); + // The subscription fires inside the evaluator's synchronized initialization, before it + // assigns the runtime: wait for the evaluator to release its monitor. + synchronized (evaluator) { + } assertFalse(other.initialize(0, MILLISECONDS, null)); assertSame(other.runtime(), evaluator.runtime());