You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/10/26 13:54:38 UTC

svn commit: r588614 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/processor/TryProcessor.java test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java

Author: jstrachan
Date: Fri Oct 26 04:54:37 2007
New Revision: 588614

URL: http://svn.apache.org/viewvc?rev=588614&view=rev
Log:
applied patch by Nicky Sandhau for CAMEL-191 with thanks

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java?rev=588614&r1=588613&r2=588614&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java Fri Oct 26 04:54:37 2007
@@ -32,7 +32,7 @@
  * @version $Revision: $
  */
 public class TryProcessor extends ServiceSupport implements Processor {
-    private static final Log LOG = LogFactory.getLog(TryProcessor.class);
+    private static final transient Log LOG = LogFactory.getLog(TryProcessor.class);
 
     private final Processor tryProcessor;
 
@@ -106,9 +106,12 @@
         for (CatchProcessor catchClause : catchClauses) {
             if (catchClause.catches(e)) {
                 // lets attach the exception to the exchange
-                exchange.setException(e);
+                Exchange localExchange = exchange.copy();
+                localExchange.getIn().setHeader("caught.exception", e);
+                // give the rest of the pipeline another chance
+                localExchange.setException(null);
                 try {
-                    catchClause.process(exchange);
+                    catchClause.process(localExchange);
                 } catch (Exception e1) {
                     LOG.warn("Caught exception inside catch clause: " + e1, e1);
                     throw e1;

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java?rev=588614&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java Fri Oct 26 04:54:37 2007
@@ -0,0 +1,25 @@
+/**
+ * 
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * The handle catch clause has a pipeline processing the exception.
+ * 
+ * @author <a href="mailto:nsandhu">nsandhu</a>
+ * 
+ */
+public class ValidationWithHandlePipelineTest extends ValidationTest {
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").tryBlock().process(validator).to("mock:valid").handle(
+                        ValidationException.class).pipeline("direct:a", "mock:invalid");
+            }
+        };
+    }
+
+}

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java
------------------------------------------------------------------------------
    svn:eol-style = native