I have some CompletableFutures and I want to run them in parallel, waiting for the first that returns normally.
I know I can use
Considering that:
One of the foundations of the philosophy of Java is to prevent or discourage bad programming practices.
(To what degree it has been successful in doing so is the subject of another debate; the point still stands that this has undeniably been one of the primary aims of the language.)
Ignoring exceptions is a very bad practice.
An exception should always be either rethrown to the layer above, or handled, or at the very least reported. Specifically, an exception should never be silently swallowed.
Errors should be reported at the earliest time possible.
for example, see the pains the runtime goes through in order to provide fail fast iterators which throw a ConcurrentModificationException if the collection is modified while iterating.
Ignoring an exceptionally completed CompletableFuture means that a) you are not reporting an error at the earliest time possible, and b) you are likely planning to not report it at all.
The inability to simply wait for the first non-exceptional completion and instead having to be bothered by exceptional completions does not impose any significant burden, because you can always remove the exceptionally completed item from the list, (while at the same time not forgetting to report the failure, right?) and repeat the wait.
I would therefore not be surprised if the sought-for feature is intentionally missing from Java, and I would be willing to argue that it is rightfully missing.
(Sorry Sotirios, no canonical answer.)