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/02/06 09:47:19 UTC
[3/3] camel git commit: CAMEL-9555: Setting
deadLetterHandleNewException to false breaks DeadLetterChannel default
exception handling.
CAMEL-9555: Setting deadLetterHandleNewException to false breaks DeadLetterChannel default exception handling.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/66801bf0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/66801bf0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/66801bf0
Branch: refs/heads/camel-2.15.x
Commit: 66801bf05cbef5b49c5c735c8434ba3253d3dd72
Parents: c4b131d
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Feb 6 09:41:39 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Feb 6 09:46:55 2016 +0100
----------------------------------------------------------------------
.../camel/processor/RedeliveryErrorHandler.java | 5 +-
...DeadLetterChannelHandleNewExceptionTest.java | 73 ++++++++++++++++++++
2 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/66801bf0/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
index da63f3c..90f4076 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
@@ -966,8 +966,9 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
// special situations when using dead letter channel
if (isDeadLetterChannel) {
- // use the handled option from the DLC
- boolean handled = data.handleNewException;
+ // DLC is always handling the first thrown exception,
+ // but if its a new exception then use the configured option
+ boolean handled = newException == null || data.handleNewException;
// when using DLC then log new exception whether its being handled or not, as otherwise it may appear as
// the DLC swallow new exceptions by default (which is by design to ensure the DLC always complete,
http://git-wip-us.apache.org/repos/asf/camel/blob/66801bf0/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandleNewExceptionTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandleNewExceptionTest.java b/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandleNewExceptionTest.java
new file mode 100644
index 0000000..8770099
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandleNewExceptionTest.java
@@ -0,0 +1,73 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class DeadLetterChannelHandleNewExceptionTest extends ContextTestSupport {
+
+ // should not log any exceptions in the log as they are all handled
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ public void testDeadLetterChannelHandleNewException() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ errorHandler(deadLetterChannel("mock:dead")
+ .deadLetterHandleNewException(true));
+
+ from("direct:start")
+ .log("Incoming ${body}")
+ .throwException(new IllegalArgumentException("Forced"));
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:dead").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testDeadLetterChannelNotHandleNewException() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ errorHandler(deadLetterChannel("mock:dead")
+ .deadLetterHandleNewException(false));
+
+ from("direct:start")
+ .log("Incoming ${body}")
+ .throwException(new IllegalArgumentException("Forced"));
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:dead").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
\ No newline at end of file