Interface Stage.OnTerminate

All Superinterfaces:
Stage
Enclosing interface:
Stage

public static interface Stage.OnTerminate extends Stage
A stage returning a stream containing all the elements from this stream, additionally performing the provided action if this stream terminates with an error, completes, or is cancelled by downstream.

The given action cannot determine in which state the stream is (error, completed or cancelled). Use Stage.OnError and Stage.OnComplete if you need to distinguish between these cases.

The action must only be invoked once. If both upstream completes, and downstream cancels, at the same time, only one of those signals may trigger the invocation of action.

If this action is invoked as the result of an upstream completion or error, any RuntimeException thrown by the function must be propagated downstream as an error, replacing the exception that the consumer was handling. If the action is invoked as the result of downstream cancellation, then any exceptions thrown by the function must be ignored, and cancellation must be propagated upstream.

  • Method Details

    • getAction

      Runnable getAction()
      The action to execute.
      Returns:
      the action to execute.