Depending on how you view it the CompletableFuture
API leaves a lot to be desired, but one the most irritating things for me, which I come across over and over again, is that it is trivial to construct a normally completed future in one line:
return CompletableFuture.completedFuture(result);
yet it is very verbose to construct an exceptionally completed future:
CompletableFuture<T> res = new CompletableFuture<>();
res.completeExceptionally(theCause);
return res;
Am I missing something and there is somewhere a sensible one-liner on the existing API or is the API really half-backed? I know I can turn the above latter case into a utility, but such a utility should be on the API, given that the above former one is there.