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:17 UTC

[1/3] camel git commit: CAMEL-9555: Setting deadLetterHandleNewException to false breaks DeadLetterChannel default exception handling.

Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x c4b131d73 -> 66801bf05
  refs/heads/camel-2.16.x 8617e146d -> 6a5a4b483
  refs/heads/master 96d5ef0b5 -> 5fd132804


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/5fd13280
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5fd13280
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5fd13280

Branch: refs/heads/master
Commit: 5fd132804155381ceebe43ec8192ed463ed5e7a5
Parents: 96d5ef0
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:41:39 2016 +0100

----------------------------------------------------------------------
 .../camel/processor/RedeliveryErrorHandler.java |  7 +-
 ...DeadLetterChannelHandleNewExceptionTest.java | 73 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5fd13280/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 e5158ed..5e48c3e 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
@@ -1043,8 +1043,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,
@@ -1057,7 +1058,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
                     } else {
                         msg += ". The new exception is not handled as deadLetterHandleNewException=false.";
                     }
-                    logFailedDelivery(false, true, handled, false, isDeadLetterChannel, exchange, msg, data, newException);
+                    logFailedDelivery(false, true, handled, false, true, exchange, msg, data, newException);
                 }
 
                 if (handled) {

http://git-wip-us.apache.org/repos/asf/camel/blob/5fd13280/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


[3/3] camel git commit: CAMEL-9555: Setting deadLetterHandleNewException to false breaks DeadLetterChannel default exception handling.

Posted by da...@apache.org.
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


[2/3] camel git commit: CAMEL-9555: Setting deadLetterHandleNewException to false breaks DeadLetterChannel default exception handling.

Posted by da...@apache.org.
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/6a5a4b48
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6a5a4b48
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6a5a4b48

Branch: refs/heads/camel-2.16.x
Commit: 6a5a4b4838680101de3a5b0a13e796e7e5d6d5a5
Parents: 8617e14
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:45:38 2016 +0100

----------------------------------------------------------------------
 .../camel/processor/RedeliveryErrorHandler.java |  7 +-
 ...DeadLetterChannelHandleNewExceptionTest.java | 73 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6a5a4b48/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 d99e5cf..ff94da7 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
@@ -1007,8 +1007,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,
@@ -1021,7 +1022,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
                     } else {
                         msg += ". The new exception is not handled as deadLetterHandleNewException=false.";
                     }
-                    logFailedDelivery(false, true, handled, false, isDeadLetterChannel, exchange, msg, data, newException);
+                    logFailedDelivery(false, true, handled, false, true, exchange, msg, data, newException);
                 }
 
                 if (handled) {

http://git-wip-us.apache.org/repos/asf/camel/blob/6a5a4b48/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