Skip to content

test(dedup): gate CompletableFuture thenAccept fixtures with a latch - #205

Merged
slayerjain merged 1 commit into
mainfrom
fix/forked-cf-latch
Dec 4, 2026
Merged

slayerjain merged 1 commit into
mainfrom
fix/forked-cf-latch

Conversation

@slayerjain

Copy link
Copy Markdown
Member

Summary

  • Eliminate a timing race in AsyncHonestyApp (/cf-then-accept and /external-cf-dependent) where a 20ms/25ms sleep could allow the upstream CompletableFuture to complete before .thenAccept(...) attached on a busy host, running the dependent inline on the servlet thread and causing ForkedAsyncAndHonestyTest windowCut:true assertions to flake.
  • Add a latch-gated overload FakeExternalHttpClient.fetchAsync(CountDownLatch, String) and release each latch in a finally block after .thenAccept(...) is attached and the HTTP response is flushed.

Verification

  • 5 consecutive stress runs of both forkedExternalJacocoPrefixModeTracksCompletableFutureDependentsAndChainedAsync and forkedExternalCfDependentAndConcreteAsyncFormsAreTrackedOrFlagged: PASS (5/5).
  • Full mvn -B test suite: 472/472 PASS, 0 failures, 0 errors, 0 skipped.

In AsyncHonestyApp, /cf-then-accept and /external-cf-dependent relied on
20ms and 25ms sleeps before completing their upstream CompletableFuture.
On a busy host the HTTP servlet thread could stall past 20-25ms before
attaching .thenAccept(...), causing the dependent to run inline on the
servlet thread before the HTTP response was sent and flaking the
windowCut:true assertions in ForkedAsyncAndHonestyTest.

Gate both upstream completions on a CountDownLatch released in a finally
block after .thenAccept(...) attaches and the HTTP response flushes.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain merged commit edb384d into main Dec 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant