Returns a new CompletionStage with the same result or exception as this stage, that executes the given action when this stage completes.
When this stage is complete, the given action is invoked
with the result (or null if none) and the exception (or
null if none) of this stage as arguments. The returned
stage is completed when the action returns.
Unlike method handle,
this method is not designed to translate completion outcomes,
so the supplied action should not throw an exception. However,
if it does, the following rules apply: if this stage completed
normally but the supplied action throws an exception, then the
returned stage completes exceptionally with the supplied
action's exception. Or, if this stage completed exceptionally
and the supplied action throws an exception, then the returned
stage completes exceptionally with this stage's exception.
action | the action to perform |
Diagram: Future