completablefuture: CompletableFuture module (thenApply vs thenCompose and the serial trap, which thread runs a stage incl. join() running dependents, CompletionException wrapping, orTimeout/cancel not stopping work, allOf/anyOf with fail-fast and first-success helpers, virtual-thread timings, StructuredTaskScope preview error), 26 contract tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b3dRuKRhrHFPzWSSxr
This commit is contained in:
Ankur Mhatre
2026-11-22 18:56:47 +05:30
co-authored by Claude Sonnet 5.5
parent 59a5435825
commit 9c2ae10d7f
25 changed files with 1335 additions and 0 deletions
@@ -0,0 +1,11 @@
== 1. thenApply with a function that itself returns a CompletableFuture
nested.join() is a: CompletableFuture
inner.join() is: Order[userId=1, item=laptop]
== 2. thenCompose flattens it
flat.join() is: Order[userId=1, item=laptop]
== 3. Same three tools, measured (fixed pool of 4, so nothing queues)
dependent calls: thenCompose (100 ms then 150 ms) -> Order[userId=1, item=laptop] 251 ms
independent calls: start both, then thenCombine -> ankur + winter-sale 125 ms
independent calls, wrongly chained with thenCompose -> ankur + winter-sale 221 ms