Java – completable future has been completed with exceptions
•
Java
CompletableFuture. Completedfuture() returns the completedfuture that has been completed with the given value
How do we build a completable future that has been abnormally completed?
I hope to throw an exception in the future instead of returning a value
Solution
I just found this:
CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(t);
There is no static factory method, but the default constructor seems to do the job
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码