![JAR search and dependency download from the Maven repository](/logo.png)
org.zeroturnaround.exec.MDCRunnableAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zt-exec Show documentation
Show all versions of zt-exec Show documentation
A lightweight library to execute external processes from Java.
package org.zeroturnaround.exec;
import java.util.Map;
import org.slf4j.MDC;
/**
* Restores the MDC context map for the target action.
*/
public class MDCRunnableAdapter implements Runnable {
private final Runnable target;
private final Map contextMap;
public MDCRunnableAdapter(Runnable target, Map contextMap) {
this.target = target;
this.contextMap = contextMap;
}
public void run() {
MDC.setContextMap(contextMap);
try {
target.run();
}
finally {
MDC.clear();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy