Top Description Fields Constructors Methods
reactor.core.publisher

public abstract Class Hooks

extends Object
Class Inheritance
Imports
java.util.*, java.util.concurrent.Callable, java.util.function.BiFunction, .Consumer, .Function, org.reactivestreams.Publisher, reactor.core.Exceptions, reactor.core.publisher.FluxOnAssembly.AssemblySnapshot, .FluxOnAssembly.MethodReturnSnapshot, reactor.core.scheduler.Schedulers, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable, reactor.util.context.Context, .ContextView

A set of overridable lifecycle hooks that can be used for cross-cutting added behavior on Flux/Mono operators.

Field Summary

Modifier and TypeField and Description
private static final String
pack-priv static boolean
pack-priv static boolean
pack-priv static final String
KEY_ON_DISCARD

A key that can be used to store a sequence-specific onDiscard(Consumer) hook in a Context, as a Consumer<Object>.

pack-priv static final String
KEY_ON_ERROR_DROPPED

A key that can be used to store a sequence-specific Hooks#onErrorDropped(Consumer) hook in a Context, as a Consumer<Throwable>.

pack-priv static final String
KEY_ON_NEXT_DROPPED

A key that can be used to store a sequence-specific Hooks#onNextDropped(Consumer) hook in a Context, as a Consumer<Object>.

pack-priv static final String
KEY_ON_OPERATOR_ERROR

A key that can be used to store a sequence-specific Hooks#onOperatorError(BiFunction) hook in a Context, as a BiFunction<Throwable, Object, Throwable>.

pack-priv static final String
KEY_ON_REJECTED_EXECUTION

A key that can be used to store a sequence-specific Hooks#onOperatorError(BiFunction) hook THAT IS ONLY APPLIED TO OperatorsonRejectedExecution in a Context, as a BiFunction<Throwable, Object, Throwable>.

pack-priv static final Logger
pack-priv static Function<Publisher<T>, Publisher<T>>
private static final LinkedHashMap<String, Function<? super Publisher<Object>, ? extends Publisher<Object>>>
pack-priv static volatile Consumer<? super Throwable>
pack-priv static volatile Function<Publisher<T>, Publisher<T>>
private static final LinkedHashMap<String, Function<? super Publisher<Object>, ? extends Publisher<Object>>>
pack-priv static volatile Consumer<Object>
pack-priv static volatile OnNextFailureStrategy
pack-priv static volatile BiFunction<? super Throwable, Object, ? extends Throwable>
private static final LinkedHashMap<String, BiFunction<? super Throwable, Object, ? extends Throwable>>
private static Function<Queue<?>, Queue<?>>
private static final LinkedHashMap<String, Function<Queue<?>, Queue<?>>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static <T, P extends Publisher<T>> Publisher<T>
public static <T, P extends Publisher<T>> Publisher<T>
addCallSiteInfo(P publisher, String callSite)

Deprecated Should only be used by the instrumentation, DOES NOT guarantee any compatibility
public static void
addQueueWrapper(String key, Function<Queue<?>, Queue<?>> decorator)

Adds a wrapper for every Queue used in Reactor.

public static <T, P extends Publisher<T>> Publisher<T>
addReturnInfo(P publisher, String method)

Deprecated Should only be used by the instrumentation, DOES NOT guarantee any compatibility
public static <
the type of data emitted by the Publisher
T
>
Flux<T>

Returns:

the Publisher wrapped as a Flux, or the original if it was a Flux
convertToFluxBypassingHooks
(Publisher<T>
the Publisher to convert to a Flux
publisher
)

Utility method to convert a Publisher to a Flux without applying Hooks.

public static <
the type of data emitted by the Publisher
T
>
Mono<T>

Returns:

the Publisher wrapped as a Mono, or the original if it was a Mono
convertToMonoBypassingHooks
(Publisher<T>
the Publisher to convert to a Mono
publisher
,
boolean
true to ensure Mono semantics (by cancelling on first onNext if source isn't already a Mono), false to perform a direct conversion (see Mono#fromDirect(Publisher)).
enforceMonoContract
)

Utility method to convert a Publisher to a Mono without applying Hooks.

pack-priv static BiFunction<? super Throwable, Object, ? extends Throwable>
pack-priv static Function<Publisher<T>, Publisher<T>>
public static void
disableAutomaticContextPropagation()

Globally disables automatic context propagation to ThreadLocals.

public static void
disableContextLossTracking()

Globally disables the Context loss detection that was previously enabled by enableContextLossTracking().

public static void
enableAutomaticContextPropagation()

Globally enables automatic context propagation to ThreadLocals.

public static void
enableContextLossTracking()

Globally enables the Context loss detection in operators like Flux#transform or Mono#transformDeferred when non-Reactor types are used.

pack-priv static final Map<String, Function<? super Publisher<Object>, ? extends Publisher<Object>>>
pack-priv static final Map<String, Function<? super Publisher<Object>, ? extends Publisher<Object>>>
pack-priv static final Map<String, BiFunction<? super Throwable, Object, ? extends Throwable>>
pack-priv static boolean
public static void
onEachOperator(Function<? super Publisher<Object>, ? extends Publisher<Object>>
the sub-hook: a function to intercept each operation call (e.g. map (fn) and map(fn2) in flux.map(fn).map(fn2).subscribe())
onEachOperator
)

Add a Publisher operator interceptor for each operator created (Flux or Mono).

public static void
onEachOperator(String
the key for the sub-hook to add/replace
key
,
Function<? super Publisher<Object>, ? extends Publisher<Object>>
the sub-hook: a function to intercept each operation call (e.g. map (fn) and map(fn2) in flux.map(fn).map(fn2).subscribe())
onEachOperator
)

Add or replace a named Publisher operator interceptor for each operator created (Flux or Mono).

public static void
onErrorDropped(Consumer<? super Throwable>
the Consumer to apply to dropped errors
c
)

Override global error dropped strategy which by default bubble back the error.

public static void
onLastOperator(Function<? super Publisher<Object>, ? extends Publisher<Object>>
the sub-hook: a function to intercept last operation call (e.g. map(fn2) in flux.map(fn).map(fn2).subscribe())
onLastOperator
)

Add a Publisher operator interceptor for the last operator created in every flow (Flux or Mono).

public static void
onLastOperator(String
the key for the sub-hook to add/replace
key
,
Function<? super Publisher<Object>, ? extends Publisher<Object>>
the sub-hook: a function to intercept last operation call (e.g. map(fn2) in flux.map(fn).map(fn2).subscribe())
onLastOperator
)

Add or replace a named Publisher operator interceptor for the last operator created in every flow (Flux or Mono).

public static void
onNextDropped(Consumer<Object>
the Consumer to apply to data (onNext) that is dropped
c
)

Override global data dropped strategy which by default logs at DEBUG level.

public static void
onNextDroppedFail()

Resets onNextDropped hook(s) and apply a strategy of throwing Exceptions#failWithCancel() instead.

public static void
onNextError(BiFunction<? super Throwable, Object, ? extends Throwable>
the new BiFunction to use.
onNextError
)

Set the custom global error mode hook for operators that support resuming during an error in their org.reactivestreams.Subscriber#onNext(Object).

public static void
onOperatorDebug()

Enable operator stack recorder that captures a declaration stack whenever an operator is instantiated.

public static void
onOperatorError(BiFunction<? super Throwable, Object, ? extends Throwable>
an operator error BiFunction mapper, returning an arbitrary exception given the failure and optionally some original context (data or error).
onOperatorError
)

Add a custom error mapping, overriding the default one.

public static void
onOperatorError(String
the key for the sub-hook to add/replace
key
,
BiFunction<? super Throwable, Object, ? extends Throwable>
an operator error BiFunction mapper, returning an arbitrary exception given the failure and optionally some original context (data or error).
onOperatorError
)

Add or replace a named custom error mapping, overriding the default one.

public static void
removeQueueWrapper(String key)

Removes existing Queue wrapper by key.

public static void
removeQueueWrappers()

Remove all queue wrappers.

public static void
resetOnEachOperator(String
the key of the sub-hook to remove
key
)

Remove the sub-hook with key key from the onEachOperator hook.

public static void
resetOnEachOperator()

Reset global "assembly" hook tracking

public static void
resetOnErrorDropped()

Reset global error dropped strategy to bubbling back the error.

public static void
resetOnLastOperator(String
the key of the sub-hook to remove
key
)

Remove the sub-hook with key key from the onLastOperator hook.

public static void
resetOnLastOperator()

Reset global "subscriber" hook tracking

public static void
resetOnNextDropped()

Reset global data dropped strategy to throwing via reactor.core.Exceptions#failWithCancel()

public static void
resetOnNextError()

Reset global onNext error handling strategy to terminating the sequence with an onError and cancelling upstream (OnNextFailureStrategy#STOP).

public static void
resetOnOperatorDebug()

Reset global operator debug.

public static void
resetOnOperatorError(String
the key of the sub-hook to remove
key
)

Remove the sub-hook with key key from the onOperatorError hook.

public static void
resetOnOperatorError()

Reset global operator error mapping to the default behavior.

public static <T> Queue<T>

Returns:

the result of applying Queue wrappers registered with addQueueWrapper(String, Function).
wrapQueue
(Queue<T>
the Queue to wrap.
queue
)

Applies the Queue wrappers that were previously registered.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait