import java.util.concurrent.CompletableFuture; class CompletableFutureTest { void foo(CompletableFuture future3, CompletableFuture future1) throws Exception { onFailure(future1.thenApply(v -> future3)); } private static CompletableFuture onFailure(CompletableFuture future) { return null; } }