From cc810aa4da7b63d6d5b28c9456d1506453f2f8b8 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Thu, 17 Mar 2011 15:15:27 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-3219 - adding missing MDCHelper class git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1082530 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/util/MDCHelper.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java 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); + } + +}