activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1082530 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java
Date Thu, 17 Mar 2011 15:15:27 GMT
Author: dejanb
Date: Thu Mar 17 15:15:27 2011
New Revision: 1082530

URL: http://svn.apache.org/viewvc?rev=1082530&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3219 - adding missing MDCHelper class

Added:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java?rev=1082530&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java (added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java Thu
Mar 17 15:15:27 2011
@@ -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);
+    }
+
+}



Mime
View raw message