org.apache.log4j.MDCFriend Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activemq-osgi Show documentation
Show all versions of activemq-osgi Show documentation
Puts together an ActiveMQ OSGi bundle
package org.apache.log4j;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.log4j.helpers.ThreadLocalMap;
public class MDCFriend {
public static void fixForJava9() {
if (MDC.mdc.tlm == null) {
MDC.mdc.tlm = new ThreadLocalMap();
MDC.mdc.java1 = false;
setRemoveMethod(MDC.mdc);
}
}
private static void setRemoveMethod(MDC mdc) {
try {
Method removeMethod = ThreadLocal.class.getMethod("remove");
Field removeMethodField = MDC.class.getDeclaredField("removeMethod");
removeMethodField.setAccessible(true);
removeMethodField.set(mdc, removeMethod);
} catch (NoSuchMethodException e) {
} catch (SecurityException e) {
} catch (NoSuchFieldException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy