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
    • 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