Interface CapturedContext

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Experimental @FunctionalInterface public interface CapturedContext
The context of a thread (tracing span, SLF4J MDC, security context, …), captured by ExecutorProvider.captureContext() so that it can be restored in tasks that run later, possibly on another thread.
Since:
1.23.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CapturedContext
    Nothing captured: tasks run unchanged.
  • Method Summary

    Modifier and Type
    Method
    Description
    wrap(Runnable task)
    Wraps a task so that it runs with the captured context.
  • Field Details

    • NONE

      static final CapturedContext NONE
      Nothing captured: tasks run unchanged.
  • Method Details

    • wrap

      Runnable wrap(Runnable task)
      Wraps a task so that it runs with the captured context. This may be called for several tasks that run at the same time, on any thread. The wrapped task must restore the previous context of the thread it runs on when it completes, normally or exceptionally.
      Parameters:
      task - the task to wrap
      Returns:
      the wrapped task