Is there a .thenCompose() for CompletableFuture that also executes exceptionally?
问题 I want to execute a CompletableFuture once another CompletableFuture finishes, regardless of whether or not the first one completes exceptionally ( .thenCompose() only runs when execution completes normally). For example: CompletableFuture.supplyAsync(() -> 1L) .whenComplete((v, e) -> CompletableFuture.runAsync(() -> { try { Thread.sleep(1000); System.out.println("HERE"); } catch(InterruptedException exc) { return; } })) .whenComplete((v, e) -> System.out.println("ALL DONE")); This prints ALL