Class MdcContext


  • public final class MdcContext
    extends Object
    Utility to copy the MDC from one thread to another thread.

    An example of the usage of this class, for a parallel stream:

     MdcContext context = MdcContext.getCurrentMdc();
    
     // stream and set context:
     list.parallelStream().forEach(entry -> { mdcContext.populateMdc(); ... })
     
    Since:
    2.0.0
    Author:
    Rutger Lubbers
    • Method Detail

      • getCurrentMdc

        public static MdcContext getCurrentMdc()
        Create a new instance.
      • populateMdc

        public void populateMdc()
        Set the copied MDC context map into the current thread's MDC.