How to invoke CompletableFuture callback while propagating result or error?
问题 I was trying .exceptionally and .handle but those don't seem to work. In scala, you can call a method on the future with a closure that is just like a finally block(it runs on exception AND on success) AND it propogates the exception or success up the chain as-is. I tried this... CompletableFuture<Object> future = newFuture.handle((r, e) -> { if(r != null) return r; else if(e != null) return e; else return new RuntimeException("Asdf"); }); Assert.assertTrue(future.isCompletedExceptionally());