Class DefaultSignalListener<T>
- All Implemented Interfaces:
SignalListener<T>
SignalListener with all the handlers no-op.- Author:
- Simon Baslé
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidHandle graceful onComplete sequence termination, after onComplete has been propagated downstream.voiddoAfterError(Throwable error) Handle onError sequence termination after onError has been propagated downstream.voiddoFinally(SignalType terminationType) Handle terminal signals after the signals have been propagated, as the final step.voiddoFirst()Handle the very beginning of theSubscriber-Publisherinteraction.voidHandle the downstream cancelling its currently observedSubscription.voidHandle graceful onComplete sequence termination.voidHandle onError sequence termination.voiddoOnFusion(int negotiatedFusion) Handle the negotiation of fusion between twoFuseableoperators.voidHandle malformedSubscriber.onComplete(), which means the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable).voiddoOnMalformedOnError(Throwable error) Handle malformedSubscriber.onError(Throwable), which means the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable).voiddoOnMalformedOnNext(T value) Handle malformedSubscriber.onNext(Object), which are onNext happening after the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable).voidHandle a new value emission from the source.voiddoOnRequest(long requested) Handle a new request made by the downstream, exposing the demand.voidHandle the fact that the upstreamPublisheracknowledgedSubscription.protected intReturn the fusion mode negotiated with the source:Fuseable.SYNCandFuseable.ASYNC) as relevant if some fusion was negotiated.voidhandleListenerError(Throwable listenerError) A special handler for exceptions thrown from all the other handlers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface reactor.core.observability.SignalListener
addToContext
-
Constructor Details
-
DefaultSignalListener
public DefaultSignalListener()
-
-
Method Details
-
doFirst
Description copied from interface:SignalListenerHandle the very beginning of theSubscriber-Publisherinteraction. This handler is invoked right before subscribing to the parentPublisher, as a downstreamSubscriberhas calledPublisher.subscribe(Subscriber).Once the
Publisherhas acknowledged with aSubscription, theSignalListener.doOnSubscription()handler will be invoked before thatSubscriptionis passed down.- Specified by:
doFirstin interfaceSignalListener<T>- Throws:
Throwable- See Also:
-
doFinally
Description copied from interface:SignalListenerHandle terminal signals after the signals have been propagated, as the final step. OnlySignalType.ON_COMPLETE,SignalType.ON_ERRORorSignalType.CANCELcan be passed. This handler is invoked AFTER the terminal signal has been propagated, and if relevant AFTER theSignalListener.doAfterComplete()orSignalListener.doAfterError(Throwable)events. If any doOnXxx handler throws, this handler is NOT invoked (seeSignalListener.handleListenerError(Throwable)instead).- Specified by:
doFinallyin interfaceSignalListener<T>- Throws:
Throwable- See Also:
-
doOnSubscription
Description copied from interface:SignalListenerHandle the fact that the upstreamPublisheracknowledgedSubscription. TheSubscriptionis intentionally not exposed in order to avoid manipulation by the observer.While
SignalListener.doFirst()is invoked right as the downstreamSubscriberis registered, this method is invoked as the upstream answers back with aSubscription(and before that sameSubscriptionis passed downstream).- Specified by:
doOnSubscriptionin interfaceSignalListener<T>- Throws:
Throwable- See Also:
-
doOnFusion
Description copied from interface:SignalListenerHandle the negotiation of fusion between twoFuseableoperators. As the downstream operator requests fusion, the upstream answers back with the compatible level of fusion it can handle. ThisnegotiatedFusioncode is passed to this handler right before it is propagated downstream.- Specified by:
doOnFusionin interfaceSignalListener<T>- Parameters:
negotiatedFusion- the final fusion mode negotiated by the upstream operator in response to a fusion request from downstream- Throws:
Throwable
-
getFusionMode
protected int getFusionMode()Return the fusion mode negotiated with the source:Fuseable.SYNCandFuseable.ASYNC) as relevant if some fusion was negotiated.Fuseable.NONEif fusion was never requested, or if it couldn't be negotiated.- Returns:
- the negotiated fusion mode, if any
-
doOnRequest
Description copied from interface:SignalListenerHandle a new request made by the downstream, exposing the demand.This is invoked before the request is propagated upstream.
- Specified by:
doOnRequestin interfaceSignalListener<T>- Parameters:
requested- the downstream demand- Throws:
Throwable
-
doOnCancel
Description copied from interface:SignalListenerHandle the downstream cancelling its currently observedSubscription.This handler is invoked before propagating the cancellation upstream, while
SignalListener.doFinally(SignalType)is invoked right after the cancellation has been propagated upstream.- Specified by:
doOnCancelin interfaceSignalListener<T>- Throws:
Throwable- See Also:
-
doOnNext
Description copied from interface:SignalListenerHandle a new value emission from the source.This handler is invoked before propagating the value downstream.
- Specified by:
doOnNextin interfaceSignalListener<T>- Parameters:
value- the emitted value- Throws:
Throwable
-
doOnComplete
Description copied from interface:SignalListenerHandle graceful onComplete sequence termination.This handler is invoked before propagating the completion downstream, while both
SignalListener.doAfterComplete()andSignalListener.doFinally(SignalType)are invoked after.- Specified by:
doOnCompletein interfaceSignalListener<T>- Throws:
Throwable- See Also:
-
doOnError
Description copied from interface:SignalListenerHandle onError sequence termination.This handler is invoked before propagating the error downstream, while both
SignalListener.doAfterError(Throwable)andSignalListener.doFinally(SignalType)are invoked after.- Specified by:
doOnErrorin interfaceSignalListener<T>- Parameters:
error- the exception that terminated the sequence- Throws:
Throwable- See Also:
-
doAfterComplete
Description copied from interface:SignalListenerHandle graceful onComplete sequence termination, after onComplete has been propagated downstream.This handler is invoked after propagating the completion downstream, similar to
SignalListener.doFinally(SignalType)and unlikeSignalListener.doOnComplete().- Specified by:
doAfterCompletein interfaceSignalListener<T>- Throws:
Throwable
-
doAfterError
Description copied from interface:SignalListenerHandle onError sequence termination after onError has been propagated downstream.This handler is invoked after propagating the error downstream, similar to
SignalListener.doFinally(SignalType)and unlikeSignalListener.doOnError(Throwable).- Specified by:
doAfterErrorin interfaceSignalListener<T>- Parameters:
error- the exception that terminated the sequence- Throws:
Throwable
-
doOnMalformedOnNext
Description copied from interface:SignalListenerHandle malformedSubscriber.onNext(Object), which are onNext happening after the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable). Note that after this handler is invoked, the value is automaticallydropped.If this handler fails with an exception, that exception is
droppedbefore the value is also dropped.- Specified by:
doOnMalformedOnNextin interfaceSignalListener<T>- Parameters:
value- the value for which an emission was attempted (which will be automatically dropped afterwards)- Throws:
Throwable
-
doOnMalformedOnComplete
Description copied from interface:SignalListenerHandle malformedSubscriber.onComplete(), which means the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable).If this handler fails with an exception, that exception is
dropped.- Specified by:
doOnMalformedOnCompletein interfaceSignalListener<T>- Throws:
Throwable
-
doOnMalformedOnError
Description copied from interface:SignalListenerHandle malformedSubscriber.onError(Throwable), which means the sequence has already terminated viaSubscriber.onComplete()orSubscriber.onError(Throwable). Note that after this handler is invoked, the exception is automaticallydropped.If this handler fails with an exception, that exception is
droppedbefore the original onError exception is also dropped.- Specified by:
doOnMalformedOnErrorin interfaceSignalListener<T>- Parameters:
error- the extraneous exception (which will be automatically dropped afterwards)- Throws:
Throwable
-
handleListenerError
Description copied from interface:SignalListenerA special handler for exceptions thrown from all the other handlers. This method MUST return normally, i.e. it MUST NOT throw. When aSignalListenerhandler fails, callers are expected to first invoke this method then to propagate thelistenerErrordownstream if that is possible, terminating the original sequence with the listenerError.Typically, this special handler is intended for a last chance at processing the error despite the fact that
SignalListener.doFinally(SignalType)is not triggered on handler errors. For example, recording the error in a metrics backend or cleaning up state that would otherwise be cleaned up bySignalListener.doFinally(SignalType).- Specified by:
handleListenerErrorin interfaceSignalListener<T>- Parameters:
listenerError- the exception thrown from aSignalListenerhandler method
-