Class LogContextPreservingActionListener<R>

  • All Implemented Interfaces:
    org.elasticsearch.action.ActionListener<R>

    public final class LogContextPreservingActionListener<R>
    extends Object
    implements org.elasticsearch.action.ActionListener<R>
    Restores the given ThreadContext.StoredContext and the given Log4j thread context once the listener is invoked
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.elasticsearch.action.ActionListener

        org.elasticsearch.action.ActionListener.Delegating<Response extends Object,​DelegateResponse extends Object>, org.elasticsearch.action.ActionListener.DelegatingActionListener<T extends Object>, org.elasticsearch.action.ActionListener.DelegatingFailureActionListener<T extends Object,​R extends Object>, org.elasticsearch.action.ActionListener.MappedActionListener<Response extends Object,​MappedResponse extends Object>, org.elasticsearch.action.ActionListener.RunAfterActionListener<T extends Object>, org.elasticsearch.action.ActionListener.RunBeforeActionListener<T extends Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      LogContextPreservingActionListener​(Supplier<org.elasticsearch.common.util.concurrent.ThreadContext.StoredContext> contextSupplier, Map<String,​String> logThreadContextMap, org.elasticsearch.action.ActionListener<R> delegate)  
    • Constructor Detail

      • LogContextPreservingActionListener

        public LogContextPreservingActionListener​(Supplier<org.elasticsearch.common.util.concurrent.ThreadContext.StoredContext> contextSupplier,
                                                  Map<String,​String> logThreadContextMap,
                                                  org.elasticsearch.action.ActionListener<R> delegate)
    • Method Detail

      • onResponse

        public void onResponse​(R r)
        Specified by:
        onResponse in interface org.elasticsearch.action.ActionListener<R>
      • onFailure

        public void onFailure​(Exception e)
        Specified by:
        onFailure in interface org.elasticsearch.action.ActionListener<R>
      • wrapPreservingContext

        public static <R> LogContextPreservingActionListener<R> wrapPreservingContext​(org.elasticsearch.action.ActionListener<R> listener,
                                                                                      org.elasticsearch.common.util.concurrent.ThreadContext threadContext)
        Wraps the provided action listener in a ContextPreservingActionListener that will also copy the response headers when the ThreadContext.StoredContext is closed