Package org.apache.solr.logging
Class MDCSnapshot
java.lang.Object
org.apache.solr.logging.MDCSnapshot
- All Implemented Interfaces:
Closeable,AutoCloseable
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:
-
Method Summary
-
Method Details
-
create
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-