Top Description Inners Fields Methods
reactor.core.publisher

pack-priv Interface OnNextFailureStrategy

extends BiFunction<Throwable, Object, Throwable>, BiPredicate<Throwable, Object>
Known Direct Implementers
reactor.core.publisher.OnNextFailureStrategy.ResumeStrategy, reactor.core.publisher.OnNextFailureStrategy.ResumeDropStrategy, reactor.core.publisher.OnNextFailureStrategy.LambdaOnNextErrorStrategy
Imports
java.util.function.BiConsumer, .BiFunction, .BiPredicate, .Consumer, .Predicate, org.reactivestreams.Subscription, reactor.core.Exceptions, reactor.util.annotation.Nullable, reactor.util.context.Context

A strategy to evaluate if errors that happens during an operator's onNext call can be recovered from, allowing the sequence to continue. This opt-in strategy is applied by compatible operators through the Operators#onNextError(Object, Throwable, Context, Subscription) and Operators#onNextPollError(Object, Throwable, Context) methods. See stop(), resumeDrop(), resumeDropIf(Predicate), resume(BiConsumer) and resumeIf(Predicate, BiConsumer) for the possible strategies.
Author
Simon Baslé

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
public static final String
KEY_ON_NEXT_ERROR_STRATEGY

The key that can be used to store an OnNextFailureStrategy in a Context.

public static final OnNextFailureStrategy
public static final OnNextFailureStrategy

Method Summary

Modifier and TypeMethod and Description
public default Throwable
apply(Throwable
the first function argument
throwable
,
Object
the second function argument
o
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.
public Throwable

Returns:

null if the error was processed for resume, a Throwable to propagate otherwise.
process
(Throwable
the error being recovered from.
error
,
Object
the value causing the error, null if not applicable.
value
,
Context
the Context associated with the recovering sequence.
context
)

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.

public static OnNextFailureStrategy

Returns:

a new OnNextFailureStrategy that allows resuming the sequence.
resume
(BiConsumer<Throwable, Object>
the Object> to process the recovered errors with. It must deal with potential nulls.
errorConsumer
)

A strategy that let all errors resume.

public static OnNextFailureStrategy
resumeDrop()

A strategy that let all error resume.

public static OnNextFailureStrategy
resumeDropIf(Predicate<Throwable>
the predicate to match in order to resume from an error.
causePredicate
)

A strategy that let some error resume.

public static OnNextFailureStrategy

Returns:

a new OnNextFailureStrategy that allows resuming the sequence.
resumeIf
(Predicate<Throwable>
the Predicate to use to determine if a failure should be recovered from.
causePredicate
,
BiConsumer<Throwable, Object>
the Object> to process the recovered errors with. It must deal with potential nulls.
errorConsumer
)

A strategy that let some errors resume.

public static OnNextFailureStrategy
stop()

A strategy that never let any error resume.

public boolean
test(Throwable
the first input argument
throwable
,
Object
the second input argument
o
)

Redeclares java.util.function.BiPredicate.test.

Evaluates this predicate on the given arguments.
Inherited from java.util.function.BiFunction:
andThen
Inherited from java.util.function.BiPredicate:
andnegateor

Field Detail

KEY_ON_NEXT_ERROR_STRATEGYback to summary
public static final String KEY_ON_NEXT_ERROR_STRATEGY

The key that can be used to store an OnNextFailureStrategy in a Context.

RESUME_DROPback to summary
public static final OnNextFailureStrategy RESUME_DROP
STOPback to summary
public static final OnNextFailureStrategy STOP

Method Detail

applyback to summary
public default Throwable apply(Throwable throwable, Object o)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
throwable:Throwable

the first function argument

o:Object

the second function argument

Returns:Throwable

the function result

Annotations
@Override
@Nullable
processback to summary
public Throwable process(Throwable error, Object value, Context context)

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.

If the strategy cannot resume this kind of error (ie. test(Throwable, Object) returns false), return the original error. Any exception in the processing will be caught and returned. If the strategy was able to process the error correctly, returns null.

Parameters
error:Throwable

the error being recovered from.

value:Object

the value causing the error, null if not applicable.

context:Context

the Context associated with the recovering sequence.

Returns:Throwable

null if the error was processed for resume, a Throwable to propagate otherwise.

Annotations
@Nullable
See Also
test(Throwable, Object)
resumeback to summary
public static OnNextFailureStrategy resume(BiConsumer<Throwable, Object> errorConsumer)

A strategy that let all errors resume. When processing, the error and the incriminating source value are passed to custom Consumers.

Any exception thrown by the consumers will suppress the original error and be returned for propagation. If the original error is fatal then it is thrown upon processing it (see Exceptions#throwIfFatal(Throwable)).

Parameters
errorConsumer:BiConsumer<Throwable, Object>

the Object> to process the recovered errors with. It must deal with potential nulls.

Returns:OnNextFailureStrategy

a new OnNextFailureStrategy that allows resuming the sequence.

resumeDropback to summary
public static OnNextFailureStrategy resumeDrop()

A strategy that let all error resume. When processing, the error is passed to the Operators#onErrorDropped(Throwable, Context) hook and the incriminating source value (if available) is passed to the Operators#onNextDropped(Object, Context) hook, allowing the sequence to continue with further values.

resumeDropIfback to summary
public static OnNextFailureStrategy resumeDropIf(Predicate<Throwable> causePredicate)

A strategy that let some error resume. When processing, the error is passed to the Operators#onErrorDropped(Throwable, Context) hook and the incriminating source value (if available) is passed to the Operators#onNextDropped(Object, Context) hook, allowing the sequence to continue with further values.

Any exception thrown by the predicate is thrown as is.

Parameters
causePredicate:Predicate<Throwable>

the predicate to match in order to resume from an error.

resumeIfback to summary
public static OnNextFailureStrategy resumeIf(Predicate<Throwable> causePredicate, BiConsumer<Throwable, Object> errorConsumer)

A strategy that let some errors resume. When processing, the error and the incriminating source value are passed to custom Consumers.

Any exception thrown by the predicate is thrown as is. Any exception thrown by the consumers will suppress the original error and be returned for propagation. Even if the original error is fatal, if it passes the predicate then it can be processed and recovered from (see Exceptions#throwIfFatal(Throwable)).

Parameters
causePredicate:Predicate<Throwable>

the Predicate to use to determine if a failure should be recovered from.

errorConsumer:BiConsumer<Throwable, Object>

the Object> to process the recovered errors with. It must deal with potential nulls.

Returns:OnNextFailureStrategy

a new OnNextFailureStrategy that allows resuming the sequence.

stopback to summary
public static OnNextFailureStrategy stop()

A strategy that never let any error resume.

testback to summary
public boolean test(Throwable throwable, Object o)

Redeclares java.util.function.BiPredicate.test.

Doc from java.util.function.BiPredicate.test.

Evaluates this predicate on the given arguments.

Parameters
throwable:Throwable

the first input argument

o:Object

the second input argument

Returns:boolean

true if the input arguments match the predicate, otherwise false

Annotations
@Override
reactor.core.publisher back to summary

public final Class OnNextFailureStrategy.LambdaOnNextErrorStrategy

extends Object
implements OnNextFailureStrategy
Class Inheritance
  • java.lang.Object
  • reactor.core.publisher.OnNextFailureStrategy.LambdaOnNextErrorStrategy
All Implemented Interfaces
reactor.core.publisher.OnNextFailureStrategy, java.util.function.BiPredicate, java.util.function.BiFunction

Field Summary

Modifier and TypeField and Description
private final BiPredicate<? super Throwable, Object>
private final BiFunction<? super Throwable, Object, ? extends Throwable>

Constructor Summary

AccessConstructor and Description
public
LambdaOnNextErrorStrategy(BiFunction<? super Throwable, Object, ? extends Throwable> delegateProcessor)

Method Summary

Modifier and TypeMethod and Description
public Throwable
process(Throwable
the error being recovered from.
error
,
Object
the value causing the error, null if not applicable.
value
,
Context
the Context associated with the recovering sequence.
ignored
)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.
public boolean
test(Throwable
the first input argument
error
,
Object
the second input argument
value
)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Evaluates this predicate on the given arguments.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegatePredicateback to summary
private final BiPredicate<? super Throwable, Object> delegatePredicate
delegateProcessorback to summary
private final BiFunction<? super Throwable, Object, ? extends Throwable> delegateProcessor

Constructor Detail

LambdaOnNextErrorStrategyback to summary
public LambdaOnNextErrorStrategy(BiFunction<? super Throwable, Object, ? extends Throwable> delegateProcessor)
Annotations
@SuppressWarnings:unchecked

Method Detail

processback to summary
public Throwable process(Throwable error, Object value, Context ignored)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Doc from reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.

If the strategy cannot resume this kind of error (ie. test(Throwable, Object) returns false), return the original error. Any exception in the processing will be caught and returned. If the strategy was able to process the error correctly, returns null.

Parameters
error:Throwable

the error being recovered from.

value:Object

the value causing the error, null if not applicable.

ignored:Context

the Context associated with the recovering sequence.

Returns:Throwable

null if the error was processed for resume, a Throwable to propagate otherwise.

Annotations
@Override
@Nullable
testback to summary
public boolean test(Throwable error, Object value)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Doc from java.util.function.BiPredicate.test.

Evaluates this predicate on the given arguments.

Parameters
error:Throwable

the first input argument

value:Object

the second input argument

Returns:boolean

true if the input arguments match the predicate, otherwise false

Annotations
@Override
reactor.core.publisher back to summary

public final Class OnNextFailureStrategy.ResumeDropStrategy

extends Object
implements OnNextFailureStrategy
Class Inheritance
  • java.lang.Object
  • reactor.core.publisher.OnNextFailureStrategy.ResumeDropStrategy
All Implemented Interfaces
reactor.core.publisher.OnNextFailureStrategy, java.util.function.BiPredicate, java.util.function.BiFunction

Field Summary

Modifier and TypeField and Description
pack-priv final Predicate<Throwable>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Throwable
process(Throwable
the error being recovered from.
error
,
Object
the value causing the error, null if not applicable.
value
,
Context
the Context associated with the recovering sequence.
context
)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.
public boolean
test(Throwable
the first input argument
error
,
Object
the second input argument
value
)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Evaluates this predicate on the given arguments.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorPredicateback to summary
pack-priv final Predicate<Throwable> errorPredicate

Constructor Detail

ResumeDropStrategyback to summary
pack-priv ResumeDropStrategy(Predicate<Throwable> errorPredicate)

Method Detail

processback to summary
public Throwable process(Throwable error, Object value, Context context)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Doc from reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.

If the strategy cannot resume this kind of error (ie. test(Throwable, Object) returns false), return the original error. Any exception in the processing will be caught and returned. If the strategy was able to process the error correctly, returns null.

Parameters
error:Throwable

the error being recovered from.

value:Object

the value causing the error, null if not applicable.

context:Context

the Context associated with the recovering sequence.

Returns:Throwable

null if the error was processed for resume, a Throwable to propagate otherwise.

Annotations
@Override
@Nullable
testback to summary
public boolean test(Throwable error, Object value)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Doc from java.util.function.BiPredicate.test.

Evaluates this predicate on the given arguments.

Parameters
error:Throwable

the first input argument

value:Object

the second input argument

Returns:boolean

true if the input arguments match the predicate, otherwise false

Annotations
@Override
reactor.core.publisher back to summary

public final Class OnNextFailureStrategy.ResumeStrategy

extends Object
implements OnNextFailureStrategy
Class Inheritance
All Implemented Interfaces
reactor.core.publisher.OnNextFailureStrategy, java.util.function.BiPredicate, java.util.function.BiFunction

Field Summary

Modifier and TypeField and Description
pack-priv final BiConsumer<Throwable, Object>
pack-priv final Predicate<Throwable>

Constructor Summary

AccessConstructor and Description
pack-priv
ResumeStrategy(Predicate<Throwable> errorPredicate, BiConsumer<Throwable, Object> errorConsumer)

Method Summary

Modifier and TypeMethod and Description
public Throwable
process(Throwable
the error being recovered from.
error
,
Object
the value causing the error, null if not applicable.
value
,
Context
the Context associated with the recovering sequence.
context
)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.
public boolean
test(Throwable
the first input argument
error
,
Object
the second input argument
value
)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Evaluates this predicate on the given arguments.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorConsumerback to summary
pack-priv final BiConsumer<Throwable, Object> errorConsumer
errorPredicateback to summary
pack-priv final Predicate<Throwable> errorPredicate

Constructor Detail

ResumeStrategyback to summary
pack-priv ResumeStrategy(Predicate<Throwable> errorPredicate, BiConsumer<Throwable, Object> errorConsumer)

Method Detail

processback to summary
public Throwable process(Throwable error, Object value, Context context)

Implements reactor.core.publisher.OnNextFailureStrategy.process.

Doc from reactor.core.publisher.OnNextFailureStrategy.process.

Process an error and the optional value that caused it (when applicable) in preparation for sequence resume, so that the error is not completely swallowed.

If the strategy cannot resume this kind of error (ie. test(Throwable, Object) returns false), return the original error. Any exception in the processing will be caught and returned. If the strategy was able to process the error correctly, returns null.

Parameters
error:Throwable

the error being recovered from.

value:Object

the value causing the error, null if not applicable.

context:Context

the Context associated with the recovering sequence.

Returns:Throwable

null if the error was processed for resume, a Throwable to propagate otherwise.

Annotations
@Override
@Nullable
testback to summary
public boolean test(Throwable error, Object value)

Implements reactor.core.publisher.OnNextFailureStrategy.test.

Doc from java.util.function.BiPredicate.test.

Evaluates this predicate on the given arguments.

Parameters
error:Throwable

the first input argument

value:Object

the second input argument

Returns:boolean

true if the input arguments match the predicate, otherwise false

Annotations
@Override