You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ro...@apache.org on 2008/02/29 21:35:09 UTC
svn commit: r632429 - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/processor/ test/java/org/apache/camel/builder/
test/java/org/apache/camel/processor/
Author: romkal
Date: Fri Feb 29 12:35:01 2008
New Revision: 632429
URL: http://svn.apache.org/viewvc?rev=632429&view=rev
Log:
CAMEL-346 : Exception handler doesn't swallow exceptions anymore
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java (with props)
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java (with props)
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java (with props)
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/BuilderWithScopesTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.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=632429&r1=632428&r2=632429&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 Feb 29 12:35:01 2008
@@ -69,9 +69,7 @@
if (e != null) {
try {
- DeadLetterChannel.setFailureHandled(exchange, true);
handleException(exchange, e);
- exchange.setException(null);
} catch (Exception ex) {
throw ex;
} catch (Throwable ex) {
@@ -92,6 +90,7 @@
finallyProcessor.process(exchange);
} catch (Exception e2) {
LOG.warn("Caught exception in finally block while handling other exception: " + e2, e2);
+ exchange.setException(e2);
}
}
}
@@ -117,7 +116,7 @@
ExchangeHelper.copyResults(exchange, localExchange);
} catch (Exception e1) {
LOG.warn("Caught exception inside catch clause: " + e1, e1);
- throw e1;
+ exchange.setException(e1);
}
return;
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/BuilderWithScopesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/BuilderWithScopesTest.java?rev=632429&r1=632428&r2=632429&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/BuilderWithScopesTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/BuilderWithScopesTest.java Fri Feb 29 12:35:01 2008
@@ -17,6 +17,7 @@
package org.apache.camel.builder;
import java.util.ArrayList;
+import java.util.Collections;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
@@ -268,7 +269,7 @@
public void testRouteWithTryCatchNoEndWithUncaughtException() throws Exception {
ArrayList<String> expected = new ArrayList<String>();
- expected.add("VALIDATE");
+ expected.addAll(Collections.nCopies(6, "VALIDATE"));
runTest(createTryCatchNoEnd(), expected);
}
@@ -305,7 +306,7 @@
public void testRouteWithTryCatchEndWithUncaughtException() throws Exception {
ArrayList<String> expected = new ArrayList<String>();
- expected.add("VALIDATE");
+ expected.addAll(Collections.nCopies(6, "VALIDATE"));
runTest(createTryCatchEnd(), expected);
}
Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java?rev=632429&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java Fri Feb 29 12:35:01 2008
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+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 ValidationWithHandlePipelineAndExceptionTest extends ValidationTest {
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ exception(ValidationException.class).to("mock:invalid");
+
+ from("direct:start").tryBlock().process(validator).to("mock:valid").handle(
+ ValidationException.class).process(validator);
+ }
+ };
+ }
+
+}
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineAndExceptionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: 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=632429&r1=632428&r2=632429&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithHandlePipelineTest.java Fri Feb 29 12:35:01 2008
@@ -16,8 +16,14 @@
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");
+ from("direct:start")
+ .tryBlock()
+ .process(validator).to("mock:valid")
+ .handle(ValidationException.class)
+ .tryBlock()
+ .process(validator).to("mock:valid")
+ .handle(ValidationException.class)
+ .pipeline("direct:a", "mock:invalid");
}
};
}
Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java?rev=632429&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java Fri Feb 29 12:35:01 2008
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision: 630568 $
+ */
+public class ValidationWithInFlowExceptionTest extends ValidationTest {
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ exception(ValidationException.class).to("mock:invalid");
+
+ from("direct:start").
+ exception(ValidationException.class).to("mock:invalid").
+ end().
+ process(validator).
+ to("mock:valid");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithInFlowExceptionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java?rev=632429&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java Fri Feb 29 12:35:01 2008
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+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 ValidationWithMultipleHandlesTest extends ValidationTest {
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .tryBlock()
+ .process(validator)
+ .handle(ValidationException.class)
+ .setHeader("xxx", constant("yyy"))
+ .end()
+ .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/ValidationWithMultipleHandlesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain