Module mutiny.zero

Class Recover<T>

java.lang.Object
mutiny.zero.operators.Recover<T>
Type Parameters:
T - the elements type
All Implemented Interfaces:
Flow.Publisher<T>

public class Recover<T> extends Object implements Flow.Publisher<T>
A Flow.Publisher that recovers from failure using a Function.

The provided function accepts an error that would normally trigger an Flow.Subscriber.onError(Throwable) signal.

The function returns a recovery value of type T, then the stream terminates with an Flow.Subscriber.onComplete() signal. If the function returns null then the stream terminates directly with a completion event.

The stream ends with an error if the function throws an exception.

  • Constructor Details

    • Recover

      public Recover(Flow.Publisher<T> upstream, Function<Throwable,T> function)
      Build a new recovery publisher.
      Parameters:
      upstream - the upstream publisher
      function - the recovery function, must not return null values
  • Method Details