Class MdcAwareSubscriber<T>

java.lang.Object
org.forgerock.http.protocol.MdcAwareSubscriber<T>
Type Parameters:
T - the type of element signaled.
All Implemented Interfaces:
org.reactivestreams.Subscriber<T>

public final class MdcAwareSubscriber<T> extends Object implements org.reactivestreams.Subscriber<T>
An implementation of Subscriber that will preserve the SLF4J MDC.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> org.reactivestreams.Subscriber<T>
    mdcAwareSubscriber(Map<String,String> mdc, org.reactivestreams.Subscriber<T> delegate)
    Wraps the delegate Subscriber with another Subscriber instance that will use the provided MDC context when delegating the calls to the delegated Subscriber.
    static <T> org.reactivestreams.Subscriber<T>
    mdcAwareSubscriber(org.reactivestreams.Subscriber<T> delegate)
    Wraps the delegate Subscriber with another Subscriber instance that will capture the current MDC context, and will use it when delegating the calls to the delegated Subscriber.
    void
     
    void
    onError(@NonNull Throwable e)
     
    void
    onNext(T t)
     
    void
    onSubscribe(org.reactivestreams.Subscription s)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • onSubscribe

      public void onSubscribe(org.reactivestreams.Subscription s)
      Specified by:
      onSubscribe in interface org.reactivestreams.Subscriber<T>
    • onNext

      public void onNext(@NonNull T t)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<T>
    • onError

      public void onError(@NonNull @NonNull Throwable e)
      Specified by:
      onError in interface org.reactivestreams.Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface org.reactivestreams.Subscriber<T>
    • mdcAwareSubscriber

      public static <T> org.reactivestreams.Subscriber<T> mdcAwareSubscriber(org.reactivestreams.Subscriber<T> delegate)
      Wraps the delegate Subscriber with another Subscriber instance that will capture the current MDC context, and will use it when delegating the calls to the delegated Subscriber.
      Type Parameters:
      T - the type of element signaled.
      Parameters:
      delegate - the Subscriber to delegate the calls to
      Returns:
      A Subscriber that will position the captured MDC context before each call.
      See Also:
    • mdcAwareSubscriber

      public static <T> org.reactivestreams.Subscriber<T> mdcAwareSubscriber(Map<String,String> mdc, org.reactivestreams.Subscriber<T> delegate)
      Wraps the delegate Subscriber with another Subscriber instance that will use the provided MDC context when delegating the calls to the delegated Subscriber.
      Type Parameters:
      T - the type of element signaled.
      Parameters:
      mdc - The MDC to use when delegating the calls
      delegate - the Subscriber to delegate the calls to
      Returns:
      A Subscriber that will position the captured MDC context before each call.