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

Pafsanias Ftakas commented on CAMEL-11983:
------------------------------------------

Stack trace thrown when the race condition occurs:
{{
2017-11-02 15:38:58.181 ERROR 2709 --- [TaskExecutor-14] 
.a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected error occurred invoking 
async method 'public void com.example.demo.DoSomethingService.doSomething(int)'.

org.apache.camel.CamelExecutionException: Exception occurred during execution 
on the exchange: Exchange[ID-Pafsaniass-MacBook-Pro-local-1509629927258-0-3]
        at 
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1847)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:713) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:515)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:511)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:163)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:168)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
com.example.demo.DoSomethingService.doSomething(DoSomethingService.java:20) 
~[classes/:na]
        at 
com.example.demo.DoSomethingService$$FastClassBySpringCGLIB$$42aeb0a0.invoke(<generated>)
 ~[classes/:na]
        at 
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) 
~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
        at 
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
 ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
 ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
        at 
org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115)
 ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
[na:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: java.lang.IllegalArgumentException: template must be specified
        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:323) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:100) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.util.toolbox.XsltAggregationStrategy.aggregate(XsltAggregationStrategy.java:107)
 ~[camel-core-2.20.0.jar:2.20.0]
        at org.apache.camel.processor.Enricher.process(Enricher.java:266) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
 ~[camel-core-2.20.0.jar:2.20.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) 
~[camel-core-2.20.0.jar:2.20.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:186)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:86)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:541) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:506) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:369) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:506) 
~[camel-core-2.20.0.jar:2.20.0]
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:229) 
~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:144)
 ~[camel-core-2.20.0.jar:2.20.0]
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:161)
 ~[camel-core-2.20.0.jar:2.20.0]
        ... 9 common frames omitted}}

> XsltAggregationStrategy thread safety during initialization
> -----------------------------------------------------------
>
>                 Key: CAMEL-11983
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11983
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-xslt
>    Affects Versions: 2.17.0
>         Environment: Apache Camel 2.17 on EAP Fuse 6.4.0
> Apache Camel 2.20 on Spring Boot standalone
>            Reporter: Pafsanias Ftakas
>            Priority: Normal
>              Labels: thread-safety
>         Attachments: reentrancy.zip
>
>
> It seems that there is a race condition in the XsltAggregatorStrategy. The 
> following code:
> {code:java}
> if (xslt == null) {
>     initialize(oldExchange.getContext());
> }
> ...
> xslt.process(oldExchange);
> {code}
> means that potentially one thread might be still working on the initialize 
> call while another thread passes through the gate of the if statement and 
> executes the xslt.process() call. If the initialization is not quite 
> complete, the XsltBuilder will throw an exception complaining that the 
> template has not been set.
> I have written a small Spring Boot project (which I am attaching to this Jira 
> issue) that demonstrates this. I understand that this only happens when 
> parallelization is present during the xslt member initialization above, and 
> that it sorts itself out in subsequent calls, but I have managed to see this 
> during testing, so it is not that impossible for it to happen.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to