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/07 18:19:21 UTC

[1/6] camel git commit: CAMEL-9573: useOriginalMessage should deal with parent/sub UoW.

Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 355adb6b9 -> 0ea3ce9a1
  refs/heads/master 848315144 -> bee0d3b04


CAMEL-9573: useOriginalMessage should deal with parent/sub UoW.


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

Branch: refs/heads/master
Commit: c710a2b43b7732d589bb2f0c12a03c7e8c513d93
Parents: 8483151
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 14:23:27 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 14:23:27 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/model/ProcessorDefinition.java | 11 +++++++--
 .../camel/processor/MulticastProcessor.java     |  2 +-
 .../camel/processor/OnCompletionProcessor.java  |  2 +-
 .../camel/processor/RedeliveryErrorHandler.java |  2 +-
 .../org/apache/camel/util/ExchangeHelper.java   | 26 ++++++++++++++++++++
 5 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c710a2b4/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index eacb304..0705d69 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -54,6 +54,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.model.language.LanguageExpression;
 import org.apache.camel.model.language.SimpleExpression;
 import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.InterceptEndpointProcessor;
 import org.apache.camel.processor.Pipeline;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
@@ -534,10 +535,16 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
             processor = createProcessor(routeContext);
         }
 
+        // unwrap internal processor so we can set id on the actual processor
+        Processor idProcessor = processor;
+        if (processor instanceof CamelInternalProcessor) {
+            idProcessor = ((CamelInternalProcessor) processor).getProcessor();
+        }
+
         // inject id
-        if (processor instanceof IdAware) {
+        if (idProcessor instanceof IdAware) {
             String id = this.idOrCreate(routeContext.getCamelContext().getNodeIdFactory());
-            ((IdAware) processor).setId(id);
+            ((IdAware) idProcessor).setId(id);
         }
 
         if (processor == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/c710a2b4/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index acc35b9..65a4d51 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -874,7 +874,7 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
         // must copy results at this point
         if (subExchange != null) {
             if (stoppedOnException) {
-                // if we stopped due an exception then only propagte the exception
+                // if we stopped due an exception then only propagate the exception
                 original.setException(subExchange.getException());
             } else {
                 // copy the current result to original so it will contain this result of this eip

http://git-wip-us.apache.org/repos/asf/camel/blob/c710a2b4/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
index bd06382..f0835b9 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
@@ -203,7 +203,7 @@ public class OnCompletionProcessor extends ServiceSupport implements AsyncProces
         if (useOriginalBody) {
             LOG.trace("Using the original IN message instead of current");
 
-            Message original = exchange.getUnitOfWork().getOriginalInMessage();
+            Message original = ExchangeHelper.getOriginalInMessage(exchange);
             answer.setIn(original);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/c710a2b4/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 5e48c3e..bdc9346 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
@@ -918,7 +918,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
             // prepare original IN body if it should be moved instead of current body
             if (data.useOriginalInMessage) {
                 log.trace("Using the original IN message instead of current");
-                Message original = exchange.getUnitOfWork().getOriginalInMessage();
+                Message original = ExchangeHelper.getOriginalInMessage(exchange);
                 exchange.setIn(original);
                 if (exchange.hasOut()) {
                     log.trace("Removing the out message to avoid some uncertain behavior");

http://git-wip-us.apache.org/repos/asf/camel/blob/c710a2b4/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java b/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
index 505f04e..9641026 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
@@ -878,6 +878,32 @@ public final class ExchangeHelper {
         }
     }
 
+    /**
+     * Gets the original IN {@link Message} this Unit of Work was started with.
+     * <p/>
+     * The original message is only returned if the option {@link org.apache.camel.RuntimeConfiguration#isAllowUseOriginalMessage()}
+     * is enabled. If its disabled, then <tt>null</tt> is returned.
+     *
+     * @return the original IN {@link Message}, or <tt>null</tt> if using original message is disabled.
+     */
+    public static Message getOriginalInMessage(Exchange exchange) {
+        Message answer = null;
+
+        // try parent first
+        UnitOfWork uow = exchange.getProperty(Exchange.PARENT_UNIT_OF_WORK, UnitOfWork.class);
+        if (uow != null) {
+            answer = uow.getOriginalInMessage();
+        }
+        // fallback to the current exchange
+        if (answer == null) {
+            uow = exchange.getUnitOfWork();
+            if (uow != null) {
+                answer = uow.getOriginalInMessage();
+            }
+        }
+        return answer;
+    }
+
     @SuppressWarnings("unchecked")
     private static Map<String, Object> safeCopy(Map<String, Object> properties) {
         if (properties == null) {


[3/6] camel git commit: Fixed test

Posted by da...@apache.org.
Fixed test


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

Branch: refs/heads/master
Commit: bee0d3b0494da5ff6525439a34ccced831c19a62
Parents: 7c826d3
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 17:13:17 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 17:13:17 2016 +0100

----------------------------------------------------------------------
 .../camel/component/file/FileProducerRenameUsingCopyTest.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bee0d3b0/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
index c5dbfb6..d318014 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
@@ -33,11 +33,12 @@ public class FileProducerRenameUsingCopyTest extends ContextTestSupport {
 
     public void testMove() throws Exception {
         final String body = "Hello Camel";
-        template.sendBodyAndHeader("file://target/file", body, Exchange.FILE_NAME, "hello.txt");
-
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedFileExists("target/file/done/hello.txt", body);
+
+        template.sendBodyAndHeader("file://target/file", body, Exchange.FILE_NAME, "hello.txt");
+
         assertMockEndpointsSatisfied();
 
         assertTrue("File not copied", new File("target/file/done/hello.txt").exists());


[5/6] camel git commit: CAMEL-9444: Added test and avoid adding the same exception multiple times when using sharedUnitOfWork

Posted by da...@apache.org.
CAMEL-9444: Added test and avoid adding the same exception multiple times when using sharedUnitOfWork


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

Branch: refs/heads/camel-2.16.x
Commit: 59c0b002441711b10a3d55ac02d3cf27e3949961
Parents: 155fae5
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 17:06:31 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 18:19:05 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultSubUnitOfWork.java |  5 +-
 ...tOfWorkOnExceptionHandledFalseIssueTest.java | 61 ++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/59c0b002/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
index 2bbc4b1..ec29df3 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
@@ -62,7 +62,10 @@ public class DefaultSubUnitOfWork implements SubUnitOfWork, SubUnitOfWorkCallbac
         if (failedExceptions == null) {
             failedExceptions = new ArrayList<Exception>();
         }
-        failedExceptions.add(exception);
+        if (!failedExceptions.contains(exception)) {
+            // avoid adding the same exception multiple times
+            failedExceptions.add(exception);
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/59c0b002/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
new file mode 100644
index 0000000..bb9f88f
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest extends ContextTestSupport {
+
+    public void testMulticast() throws Exception {
+        // TODO: CAMEL-9444: getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:start", "Hello World");
+            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")
+                    .multicast().shareUnitOfWork().stopOnException()
+                        .to("direct:b")
+                    .end()
+                    .to("mock:result");
+
+                from("direct:b")
+                    .to("mock:b")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}


[2/6] camel git commit: CAMEL-9444: Added test and avoid adding the same exception multiple times when using sharedUnitOfWork

Posted by da...@apache.org.
CAMEL-9444: Added test and avoid adding the same exception multiple times when using sharedUnitOfWork


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

Branch: refs/heads/master
Commit: 7c826d339fd0cb6a08efd7b4137fafc8ef4e408a
Parents: c710a2b
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 17:06:31 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 17:06:31 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultSubUnitOfWork.java |  5 +-
 ...tOfWorkOnExceptionHandledFalseIssueTest.java | 61 ++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c826d33/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
index 2bbc4b1..ec29df3 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultSubUnitOfWork.java
@@ -62,7 +62,10 @@ public class DefaultSubUnitOfWork implements SubUnitOfWork, SubUnitOfWorkCallbac
         if (failedExceptions == null) {
             failedExceptions = new ArrayList<Exception>();
         }
-        failedExceptions.add(exception);
+        if (!failedExceptions.contains(exception)) {
+            // avoid adding the same exception multiple times
+            failedExceptions.add(exception);
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7c826d33/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
new file mode 100644
index 0000000..bb9f88f
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MulticastShareUnitOfWorkOnExceptionHandledFalseIssueTest extends ContextTestSupport {
+
+    public void testMulticast() throws Exception {
+        // TODO: CAMEL-9444: getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:start", "Hello World");
+            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")
+                    .multicast().shareUnitOfWork().stopOnException()
+                        .to("direct:b")
+                    .end()
+                    .to("mock:result");
+
+                from("direct:b")
+                    .to("mock:b")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}


[4/6] camel git commit: CAMEL-9573: useOriginalMessage should deal with parent/sub UoW.

Posted by da...@apache.org.
CAMEL-9573: useOriginalMessage should deal with parent/sub UoW.


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

Branch: refs/heads/camel-2.16.x
Commit: 155fae5b7bd08ec7d1492f2d4c4a1b9e8a0476bf
Parents: 355adb6
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 14:23:27 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 18:18:58 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/model/ProcessorDefinition.java | 11 +++++++--
 .../camel/processor/MulticastProcessor.java     |  2 +-
 .../camel/processor/OnCompletionProcessor.java  |  2 +-
 .../camel/processor/RedeliveryErrorHandler.java |  2 +-
 .../org/apache/camel/util/ExchangeHelper.java   | 26 ++++++++++++++++++++
 5 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/155fae5b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 7bb512f..c525881 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -54,6 +54,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.model.language.LanguageExpression;
 import org.apache.camel.model.language.SimpleExpression;
 import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.InterceptEndpointProcessor;
 import org.apache.camel.processor.Pipeline;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
@@ -534,10 +535,16 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
             processor = createProcessor(routeContext);
         }
 
+        // unwrap internal processor so we can set id on the actual processor
+        Processor idProcessor = processor;
+        if (processor instanceof CamelInternalProcessor) {
+            idProcessor = ((CamelInternalProcessor) processor).getProcessor();
+        }
+
         // inject id
-        if (processor instanceof IdAware) {
+        if (idProcessor instanceof IdAware) {
             String id = this.idOrCreate(routeContext.getCamelContext().getNodeIdFactory());
-            ((IdAware) processor).setId(id);
+            ((IdAware) idProcessor).setId(id);
         }
 
         if (processor == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/155fae5b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index acc35b9..65a4d51 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -874,7 +874,7 @@ public class MulticastProcessor extends ServiceSupport implements AsyncProcessor
         // must copy results at this point
         if (subExchange != null) {
             if (stoppedOnException) {
-                // if we stopped due an exception then only propagte the exception
+                // if we stopped due an exception then only propagate the exception
                 original.setException(subExchange.getException());
             } else {
                 // copy the current result to original so it will contain this result of this eip

http://git-wip-us.apache.org/repos/asf/camel/blob/155fae5b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
index bd06382..f0835b9 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java
@@ -203,7 +203,7 @@ public class OnCompletionProcessor extends ServiceSupport implements AsyncProces
         if (useOriginalBody) {
             LOG.trace("Using the original IN message instead of current");
 
-            Message original = exchange.getUnitOfWork().getOriginalInMessage();
+            Message original = ExchangeHelper.getOriginalInMessage(exchange);
             answer.setIn(original);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/155fae5b/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 ff94da7..9697dc6 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
@@ -882,7 +882,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
             // prepare original IN body if it should be moved instead of current body
             if (data.useOriginalInMessage) {
                 log.trace("Using the original IN message instead of current");
-                Message original = exchange.getUnitOfWork().getOriginalInMessage();
+                Message original = ExchangeHelper.getOriginalInMessage(exchange);
                 exchange.setIn(original);
                 if (exchange.hasOut()) {
                     log.trace("Removing the out message to avoid some uncertain behavior");

http://git-wip-us.apache.org/repos/asf/camel/blob/155fae5b/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java b/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
index 63d8013..d14ab6f 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
@@ -864,6 +864,32 @@ public final class ExchangeHelper {
         }
     }
 
+    /**
+     * Gets the original IN {@link Message} this Unit of Work was started with.
+     * <p/>
+     * The original message is only returned if the option {@link org.apache.camel.RuntimeConfiguration#isAllowUseOriginalMessage()}
+     * is enabled. If its disabled, then <tt>null</tt> is returned.
+     *
+     * @return the original IN {@link Message}, or <tt>null</tt> if using original message is disabled.
+     */
+    public static Message getOriginalInMessage(Exchange exchange) {
+        Message answer = null;
+
+        // try parent first
+        UnitOfWork uow = exchange.getProperty(Exchange.PARENT_UNIT_OF_WORK, UnitOfWork.class);
+        if (uow != null) {
+            answer = uow.getOriginalInMessage();
+        }
+        // fallback to the current exchange
+        if (answer == null) {
+            uow = exchange.getUnitOfWork();
+            if (uow != null) {
+                answer = uow.getOriginalInMessage();
+            }
+        }
+        return answer;
+    }
+
     @SuppressWarnings("unchecked")
     private static Map<String, Object> safeCopy(Map<String, Object> properties) {
         if (properties == null) {


[6/6] camel git commit: Fixed test

Posted by da...@apache.org.
Fixed test


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

Branch: refs/heads/camel-2.16.x
Commit: 0ea3ce9a170a96785a270369af76b019adae9233
Parents: 59c0b00
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 7 17:13:17 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 7 18:19:13 2016 +0100

----------------------------------------------------------------------
 .../camel/component/file/FileProducerRenameUsingCopyTest.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0ea3ce9a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
index c5dbfb6..d318014 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameUsingCopyTest.java
@@ -33,11 +33,12 @@ public class FileProducerRenameUsingCopyTest extends ContextTestSupport {
 
     public void testMove() throws Exception {
         final String body = "Hello Camel";
-        template.sendBodyAndHeader("file://target/file", body, Exchange.FILE_NAME, "hello.txt");
-
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedFileExists("target/file/done/hello.txt", body);
+
+        template.sendBodyAndHeader("file://target/file", body, Exchange.FILE_NAME, "hello.txt");
+
         assertMockEndpointsSatisfied();
 
         assertTrue("File not copied", new File("target/file/done/hello.txt").exists());