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/12 17:54:59 UTC

[2/4] camel git commit: CAMEL-9444: Fix using shareUnitOfWork with multicast and using onException with unhandled=false.

CAMEL-9444: Fix using shareUnitOfWork with multicast and using onException with unhandled=false.


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

Branch: refs/heads/master
Commit: f35ed717aa138632d499289a56cfb6ef19d1f2b2
Parents: bf43182
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Feb 12 14:30:24 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Feb 12 17:54:51 2016 +0100

----------------------------------------------------------------------
 .../org/apache/camel/model/SplitDefinition.java |  6 --
 ...tOfWorkOnExceptionHandledFalseIssueTest.java |  4 +-
 ...tOfWorkOnExceptionHandledFalseIssueTest.java | 63 ++++++++++++++++++++
 ...tOfWorkOnExceptionHandledFalseIssueTest.java | 62 +++++++++++++++++++
 4 files changed, 127 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f35ed717/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java b/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java
index 21654ac..ccfd045 100644
--- a/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/SplitDefinition.java
@@ -119,12 +119,6 @@ public class SplitDefinition extends ExpressionNode implements ExecutorServiceAw
         Splitter answer = new Splitter(routeContext.getCamelContext(), exp, childProcessor, aggregationStrategy,
                             isParallelProcessing, threadPool, shutdownThreadPool, isStreaming, isStopOnException(),
                             timeout, onPrepare, isShareUnitOfWork, isParallelAggregate);
-        if (isShareUnitOfWork) {
-            // wrap answer in a sub unit of work, since we share the unit of work
-            CamelInternalProcessor internalProcessor = new CamelInternalProcessor(answer);
-            internalProcessor.addAdvice(new CamelInternalProcessor.SubUnitOfWorkProcessorAdvice());
-            return internalProcessor;
-        }
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f35ed717/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
index 16d0f6c..c6a0295 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
@@ -30,8 +30,8 @@ public class MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest extends Co
             template.sendBody("direct:start", "Hello World");
             fail("Should throw exception");
         } catch (Exception e) {
-//            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
-//            assertEquals("Forced", cause.getMessage());
+            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            assertEquals("Forced", cause.getMessage());
         }
 
         assertMockEndpointsSatisfied();

http://git-wip-us.apache.org/repos/asf/camel/blob/f35ed717/camel-core/src/test/java/org/apache/camel/issues/RecipientListShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RecipientListShareUnitOfWorkOnExceptionHandledFalseIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/RecipientListShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
new file mode 100644
index 0000000..ef33c9a
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/RecipientListShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RecipientListShareUnitOfWorkOnExceptionHandledFalseIssueTest extends ContextTestSupport {
+
+    public void testRecipientList() throws Exception {
+        getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedMessageCount(1);
+        getMockEndpoint("mock:c").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        try {
+            template.sendBodyAndHeader("direct:start", "Hello World", "foo", "direct:b,direct:c");
+            fail("Should throw exception");
+        } catch (Exception e) {
+            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Forced", cause.getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                    .handled(false)
+                    .to("mock:a");
+
+                from("direct:start")
+                    .recipientList(header("foo")).shareUnitOfWork().stopOnException()
+                    .to("mock:result");
+
+                from("direct:b")
+                    .to("mock:b");
+
+                from("direct:c")
+                    .to("mock:c")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f35ed717/camel-core/src/test/java/org/apache/camel/issues/SplitShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/SplitShareUnitOfWorkOnExceptionHandledFalseIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/SplitShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
new file mode 100644
index 0000000..a758788
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/SplitShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class SplitShareUnitOfWorkOnExceptionHandledFalseIssueTest extends ContextTestSupport {
+
+    public void testSplit() throws Exception {
+        getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedMessageCount(2);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:start", "Camel,Donkey");
+            fail("Should throw exception");
+        } catch (Exception e) {
+            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            assertEquals("Forced", cause.getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                    .handled(false)
+                    .to("mock:a");
+
+                from("direct:start")
+                    .split(body()).shareUnitOfWork().stopOnException()
+                        .to("direct:b")
+                    .end()
+                    .to("mock:result");
+
+                from("direct:b")
+                    .to("mock:b")
+                    .filter(body().contains("Donkey"))
+                        .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}