From 8c8aa5d431420969b9b575d682e98fd9c0f81475 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 22:52:41 +0000 Subject: [PATCH 1/3] test: poll for shutDownCalled in startWithHttp401PreventsSubsequentStart test The startWithHttp401PreventsSubsequentStart test is flaky due to a race condition. In StreamingDataSource.onError(), the production code calls resultCallback.onError() (which unblocks the test's callback.awaitError()) before setting connection401Error and calling dataSourceUpdateSink.shutDown(). The test thread can resume and call the second sds.start() before connection401Error is set, causing the second start to proceed and produce a callback. This adds a short polling loop (up to 1 second, checking every 10ms) to wait for shutDownCalled to become true before testing the second start, matching the pattern used in the startWithHttp401ShutsDownSink fix. Co-Authored-By: rlamb@launchdarkly.com --- .../sdk/android/StreamingDataSourceTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java index c56dd394..114aee02 100644 --- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java +++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java @@ -690,6 +690,15 @@ public void startWithHttp401PreventsSubsequentStart() throws Exception { assertNotNull(callback1.awaitError()); + // The background thread calls resultCallback.onError() before setting + // connection401Error and calling dataSourceUpdateSink.shutDown(), so + // we need to wait for shutDown to complete before testing the second start. + long deadline = System.currentTimeMillis() + 1000; + while (!dataSourceUpdateSink.shutDownCalled && System.currentTimeMillis() < deadline) { + Thread.sleep(10); + } + assertTrue(dataSourceUpdateSink.shutDownCalled); + // Second start should be a no-op due to connection401Error flag TrackingCallback callback2 = new TrackingCallback(); sds.start(callback2); From 806d4a0df58f07c876abeb0623a450d7f2fcdcd4 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:03:11 +0000 Subject: [PATCH 2/3] ci: re-run tests to verify flake fix (run 1) Co-Authored-By: rlamb@launchdarkly.com From fc30c1e49dc5dd868c91578fcc53b02cda28c461 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:13:53 +0000 Subject: [PATCH 3/3] ci: re-run tests to verify flake fix (run 2) Co-Authored-By: rlamb@launchdarkly.com