In light of previous related discussions of
CompletionStage/CompletableFuture on this list [1-4], there may be
interest in a very small library of mine that helps with several common
use cases that come up in practice (checked exceptions, combining
multiple futures, asynchronous try-with-resources, etc.).
I looked over your code briefly, allOf() is indeed equivalent in effect
to my Futures#collect().
The use of CompletableFuture#join() in your code may be considered
undesirable by some (including static code analyis) because it is a
blocking function -- even though it is guaranteed not to block in that
In any case, the Futures class in project java-futures also provides
Futures#shortCircuitCollect(). This is similar to Akka's
Futures#sequence(), which also has short-circuit semantics:
> I also found withFallback() useful (composing two stages and if the first
> one fails, executes the second one, and only if this fails, too,
> completes exceptionally).
I don't see the use of this method, given
> I've got the feeling, that at least some of them could fit well in the JDK.
Ditto. Though a few additions are already in the current JDK9 code base.