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:
co-authored by
Claude Sonnet 5.5
parent
59a5435825
commit
9c2ae10d7f
@@ -0,0 +1,17 @@
|
||||
== 1. orTimeout: the future fails, the task keeps running
|
||||
join() after 100 ms: CompletionException <- cause TimeoutException: null
|
||||
task finished right after that? false
|
||||
task finished 700 ms later? true
|
||||
|
||||
== 2. completeOnTimeout: a fallback value instead of an exception
|
||||
join() returned: fallback value
|
||||
|
||||
== 3. cancel(true) does not interrupt the task either
|
||||
cancel(true) returned: true
|
||||
join(): CancellationException
|
||||
task saw an interrupt? false
|
||||
task ran to the end anyway? true
|
||||
|
||||
== 4. The fix: keep the executor's Future and cancel THAT on timeout
|
||||
join(): CompletionException <- cause TimeoutException: null
|
||||
task saw an interrupt? true
|
||||
Reference in New Issue
Block a user