[ 
https://issues.apache.org/jira/browse/CAMEL-12709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16583666#comment-16583666
 ] 

Frank Olschewski edited comment on CAMEL-12709 at 8/17/18 9:18 AM:
-------------------------------------------------------------------

I think you missed the ShareUnitOfWorkAggregationStrategy in your fix.

it should be like this:
{code:java}
AggregationStrategy strategy = getAggregationStrategy();

if (strategy == null) {
    AggregationStrategy original = new UseOriginalAggregationStrategy(exchange, 
true);
    if (isShareUnitOfWork()) {
        original = new ShareUnitOfWorkAggregationStrategy(original);
    }
    setAggregationStrategyOnExchange(exchange, original);
} else {
    if (DelegateAggregationStrategy.class.isAssignableFrom(strategy)) {
       strategy = ((DelegateAggregationStrategy) strategy).getDelegate();
    }
    if (UseOriginalAggregationStrategy.class.isAssignableFrom(strategy)) {
        UseOriginalAggregationStrategy original = 
(UseOriginalAggregationStrategy) strategy;
        AggregationStrategy clone = original.newInstance(exchange);
        if (isShareUnitOfWork()) {
            clone = new ShareUnitOfWorkAggregationStrategy(clone);
        }
        setAggregationStrategyOnExchange(exchange, clone);
    }
}
return super.process(exchange, callback);
{code}


was (Author: folschewski):
I think you missed the ShareUnitOfWorkAggregationStrategy in your fix.

it should be like this:
{code:java}
if (strategy instanceof UseOriginalAggregationStrategy) {
    UseOriginalAggregationStrategy original = (UseOriginalAggregationStrategy) 
strategy;
    AggregationStrategy clone = original.newInstance(exchange);
    if (isShareUnitOfWork()) {
        clone = new ShareUnitOfWorkAggregationStrategy(clone);
    }
    setAggregationStrategyOnExchange(exchange, clone);
}

{code}

> UseOriginalAggregationStrategy in outer loops
> ---------------------------------------------
>
>                 Key: CAMEL-12709
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12709
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.21.2
>            Reporter: Matthias Humbert
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 2.21.3, 2.22.1, 2.23.0
>
>
> Using splitters with the UseOriginalAggregationStrategy +in a loop+ causes 
> the splitter to return always the same original exchange.
>  
> {code:java}
> // my code is similar to the following one:
> from("direct:myLoop")
>   .loop(simple("{{export.maxLoopsPerRun}}"))
>     .setHeader(...) // changing header fields
>     .split(body(), new UseOriginalAggregationStrategy(null, false))
>       .to("direct:handleRecord")
>     .end()
>     .log("${in.headers}") // the headers of the exchange of the very first 
> loop iteration
>   .end()
> {code}
> Reason: Once the original exchange is set by 
> UseOriginalAggregationStrategy#setOriginal(Exchange), it is not updated any 
> more for loop iterations > 1.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to