Package org.apache.solr.logging
Class MDCSnapshot
- java.lang.Object
- 
- org.apache.solr.logging.MDCSnapshot
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable
 
 public final class MDCSnapshot extends Object implements Closeable Takes a 'snapshot' of the current MDC context map which is restored on (auto) close. This can be used to ensure that no MDC values set (or overridden) inside of call stack will "leak" beyond that call stack.try (var mdcSnapshot = MDCSnapshot.create()) { assert null != mdcSnapshot; // prevent compiler warning // ... arbitrary calls to MDC methods }- See Also:
- MDC.putCloseable(java.lang.String, java.lang.String)
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static MDCSnapshotcreate()
 
- 
- 
- 
Method Detail- 
createpublic static MDCSnapshot create() 
 - 
closepublic void close() - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
- 
 
-