This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 80f0e28f6e76dc7e76824c1a3ca617de489d7202
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Apr 9 13:34:41 2021 +0200

    CAMEL-16462: camel-core - Optimize Splitter EIP to reduce object 
allocations.
---
 .../org/apache/camel/impl/engine/PooledProcessorExchangeFactory.java | 5 +++--
 .../src/main/java/org/apache/camel/processor/Splitter.java           | 4 ----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledProcessorExchangeFactory.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledProcessorExchangeFactory.java
index fe3c1d2..ed4620d 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledProcessorExchangeFactory.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledProcessorExchangeFactory.java
@@ -88,6 +88,9 @@ public class PooledProcessorExchangeFactory extends 
PrototypeProcessorExchangeFa
             }
             // create a new exchange as there was no free from the pool
             answer = new DefaultPooledExchange(exchange);
+            // if creating a copy via constructor (as above) then the unit of 
work is also
+            // copied over to answer, which we then must set to null as we do 
not want to share unit of work
+            answer.setUnitOfWork(null);
         } else {
             if (statisticsEnabled) {
                 statistics.acquired.increment();
@@ -100,8 +103,6 @@ public class PooledProcessorExchangeFactory extends 
PrototypeProcessorExchangeFa
         ExchangeHelper.copyResults(answer, exchange);
         // do not reuse message id on copy
         answer.getIn().setMessageId(null);
-        // do not share the unit of work
-        answer.setUnitOfWork(null);
         if (handover) {
             // Need to hand over the completion for async invocation
             answer.handoverCompletions(exchange);
diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
index a90091d..b822ec8 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
@@ -32,7 +32,6 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Expression;
-import org.apache.camel.ExtendedExchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
@@ -316,9 +315,6 @@ public class Splitter extends MulticastProcessor implements 
AsyncProcessor, Trac
 
     @Override
     protected void updateNewExchange(Exchange exchange, int index, 
Iterable<ProcessorExchangePair> allPairs, boolean hasNext) {
-        // do not share unit of work
-        exchange.adapt(ExtendedExchange.class).setUnitOfWork(null);
-
         exchange.setProperty(ExchangePropertyKey.SPLIT_INDEX, index);
         if (allPairs instanceof Collection) {
             // non streaming mode, so we know the total size already

Reply via email to