Practice ยท 1 of 2
The three recoveries
1. static CompletableFuture<String> recovered() โ async throwing IllegalStateException;
recover with exceptionally returning "fallback".
2. static CompletableFuture<String> handled() โ same failing async; recover with
handle returning "fallback" on error, "ok:" + result on success.
3. static CompletableFuture<String> observed() โ a SUCCEEDING async ("value"), with
whenComplete appending to a static List<String> observations (add "saw-value" on
success) โ return the future; the observation must exist after join.
4. static CompletableFuture<String> onTimeoutFallback() โ async sleeping 200ms then
returning "late"; bound with completeOnTimeout("fast-fail", 20, MILLISECONDS).
Difficulty: advanced
Back to lesson: Practice: Async drills