diff --git a/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java b/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java new file mode 100644 index 0000000000..d32d2700e4 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java @@ -0,0 +1,28 @@ +package org.apache.activemq.util; + +import org.slf4j.MDC; + +import java.util.Hashtable; +import java.util.Map; + +/** + * Helper class as MDC Log4J adapter doesn't behave well with null values + */ +public class MDCHelper { + + public static Map getCopyOfContextMap() { + Map map = MDC.getCopyOfContextMap(); + if (map == null) { + map = new Hashtable(); + } + return map; + } + + public static void setContextMap(Map map) { + if (map == null) { + map = new Hashtable(); + } + MDC.setContextMap(map); + } + +}