camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1164448 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java camel-core/src/test/java/org/apache/camel/processor/MDCResetTest.java
Date Fri, 02 Sep 2011 09:47:59 GMT
Author: davsclaus
Date: Fri Sep  2 09:47:59 2011
New Revision: 1164448

URL: http://svn.apache.org/viewvc?rev=1164448&view=rev
Log:
Merged revisions 1151362 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


Added:
    camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/MDCResetTest.java
      - copied unchanged from r1151362, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MDCResetTest.java
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  2 09:47:59 2011
@@ -1 +1 @@
-/camel/trunk:1150651,1151000,1151054,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395
+/camel/trunk:1150651,1151000,1151054,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java?rev=1164448&r1=1164447&r2=1164448&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
(original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
Fri Sep  2 09:47:59 2011
@@ -36,8 +36,22 @@ public class MDCUnitOfWork extends Defau
     public static final String MDC_ROUTE_ID = "routeId";
     public static final String MDC_TRANSACTION_KEY = "transactionKey";
 
+    private final String originalBreadcrumbId;
+    private final String originalExchangeId;
+    private final String originalCorrelationId;
+    private final String originalRouteId;
+    private final String originalTransactionKey;
+
     public MDCUnitOfWork(Exchange exchange) {
         super(exchange);
+
+        // remember existing values
+        this.originalExchangeId = MDC.get(MDC_EXCHANGE_ID);
+        this.originalBreadcrumbId = MDC.get(MDC_BREADCRUMB_ID);
+        this.originalCorrelationId = MDC.get(MDC_CORRELATION_ID);
+        this.originalRouteId = MDC.get(MDC_ROUTE_ID);
+        this.originalTransactionKey = MDC.get(MDC_TRANSACTION_KEY);
+
         // must add exchange id in constructor
         MDC.put(MDC_EXCHANGE_ID, exchange.getExchangeId());
         // and add optional correlation id
@@ -107,11 +121,31 @@ public class MDCUnitOfWork extends Defau
      * Clears information put on the MDC by this {@link MDCUnitOfWork}
      */
     public void clear() {
-        MDC.remove(MDC_BREADCRUMB_ID);
-        MDC.remove(MDC_EXCHANGE_ID);
-        MDC.remove(MDC_CORRELATION_ID);
-        MDC.remove(MDC_ROUTE_ID);
-        MDC.remove(MDC_TRANSACTION_KEY);
+        if (this.originalBreadcrumbId != null) {
+            MDC.put(MDC_BREADCRUMB_ID, originalBreadcrumbId);
+        } else {
+            MDC.remove(MDC_BREADCRUMB_ID);
+        }
+        if (this.originalExchangeId != null) {
+            MDC.put(MDC_EXCHANGE_ID, originalExchangeId);
+        } else {
+            MDC.remove(MDC_EXCHANGE_ID);
+        }
+        if (this.originalCorrelationId != null) {
+            MDC.put(MDC_CORRELATION_ID, originalCorrelationId);
+        } else {
+            MDC.remove(MDC_CORRELATION_ID);
+        }
+        if (this.originalRouteId != null) {
+            MDC.put(MDC_ROUTE_ID, originalRouteId);
+        } else {
+            MDC.remove(MDC_ROUTE_ID);
+        }
+        if (this.originalTransactionKey != null) {
+            MDC.put(MDC_TRANSACTION_KEY, originalTransactionKey);
+        } else {
+            MDC.remove(MDC_TRANSACTION_KEY);
+        }
     }
 
     @Override



Mime
View raw message