Java Concurrency Interview

CompletableFuture and async composition question 96 of 180 mid

How do exceptions propagate through a chain, and what do exceptionally, handle and whenComplete do?

A stage that throws completes exceptionally, and every downstream thenApply is skipped, carrying the failure along wrapped in a CompletionException.

The wrapping catches people out: get() throws ExecutionException, join() throws CompletionException, and the cause is your original exception in both cases. And a chain nobody ever joins, gets or handles swallows its failure completely.

completablefuture error-handling

Quiz yourself on CompletableFuture and async composition Suggest a correction