Is there still time to add a method to CompletableFuture?
I would like to have a stopIf/interruptIf method that stops a chain of CFs when the given predicate is true
Consider the following example:
If fetchUser returns null, the following steps are nonsense. At the moment, you have to copy/paste a check for a null user in both changeEmail and notifyOtherSystems steps.
- stopIf((user) -> user == null)
stopIf exceptionally completes the CF with a CompletionException.
Please note that fetchUser cannot complete exceptionally on its own, since it may be used elsewhere in the code base, where a null result has different semantics
Concurrency-interest mailing list