CompletableFuture.completedFuture() returns a CompletedFuture that is already completed with the given value.
CompletedFuture
How do we construct a CompletableFut
CompletableFut
Unlike Java 9 and later, Java 8 does not provide a static factory method for this scenario. The default constructor can be used instead:
CompletableFuture future = new CompletableFuture<>(); future.completeExceptionally(exception);