You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/01/12 12:01:53 UTC

[2/2] camel git commit: CAMEL-9504: OnCompletion - Keep caught exception so it can access the exception

CAMEL-9504: OnCompletion - Keep caught exception so it can access the exception


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f56eafa0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f56eafa0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f56eafa0

Branch: refs/heads/camel-2.15.x
Commit: f56eafa070a7491019dc668e5162ab216ce4d990
Parents: 4f0de9a
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 12 11:59:34 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 12 12:01:40 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/processor/OnCompletionProcessor.java  | 5 +----
 .../test/java/org/apache/camel/processor/OnCompletionTest.java  | 1 +
 2 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f56eafa0/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
index d46034b..bdd7080 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
@@ -127,9 +127,9 @@ public class OnCompletionProcessor extends ServiceSupport implements AsyncProces
     protected static void doProcess(Processor processor, Exchange exchange) {
         // must remember some properties which we cannot use during onCompletion processing
         // as otherwise we may cause issues
+        // but keep the caused exception stored as a property (Exchange.EXCEPTION_CAUGHT) on the exchange
         Object stop = exchange.removeProperty(Exchange.ROUTE_STOP);
         Object failureHandled = exchange.removeProperty(Exchange.FAILURE_HANDLED);
-        Object caught = exchange.removeProperty(Exchange.EXCEPTION_CAUGHT);
         Object errorhandlerHandled = exchange.removeProperty(Exchange.ERRORHANDLER_HANDLED);
         Object rollbackOnly = exchange.removeProperty(Exchange.ROLLBACK_ONLY);
         Object rollbackOnlyLast = exchange.removeProperty(Exchange.ROLLBACK_ONLY_LAST);
@@ -149,9 +149,6 @@ public class OnCompletionProcessor extends ServiceSupport implements AsyncProces
             if (failureHandled != null) {
                 exchange.setProperty(Exchange.FAILURE_HANDLED, failureHandled);
             }
-            if (caught != null) {
-                exchange.setProperty(Exchange.EXCEPTION_CAUGHT, caught);
-            }
             if (errorhandlerHandled != null) {
                 exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, errorhandlerHandled);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/f56eafa0/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java b/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
index b29dc26..be4f05e 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
@@ -43,6 +43,7 @@ public class OnCompletionTest extends ContextTestSupport {
     public void testSynchronizeFailure() throws Exception {
         getMockEndpoint("mock:sync").expectedMessageCount(1);
         getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
+        getMockEndpoint("mock:sync").message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);