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

Alex Furmanski commented on CAMEL-5469:
---------------------------------------

FYI I have encountered this exception in Camel 2.15

{noformat}
java.util.concurrent.ExecutionException: 
org.apache.camel.CamelExecutionException: Exception occurred during execution 
on the exchange: Exchange[Message: hello world]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at com.example.ConcurrencyTest.testConcurrently(ConcurrencyTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at 
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at 
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at 
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at 
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.apache.camel.CamelExecutionException: Exception occurred during 
execution on the exchange: Exchange[Message: hello world]
        at 
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635)
        at 
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:645)
        at 
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:133)
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:149)
        at com.example.ConcurrencyTest.test(ConcurrencyTest.java:25)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.util.ConcurrentModificationException
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:233)
        at 
org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeHttpClient(CxfRsProducer.java:164)
        at 
org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:90)
        at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
        at 
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:167)
        at 
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:304)
        at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:162)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
        at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
        at 
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
        at 
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
        at 
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
        at 
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375)
        at 
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343)
        at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
        at 
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343)
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201)
        at 
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
        at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
        ... 7 more
Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
        at java.util.ArrayList$Itr.next(ArrayList.java:859)
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.applyFeatures(JAXRSClientFactoryBean.java:408)
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.initClient(JAXRSClientFactoryBean.java:372)
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:225)
        ... 30 more
{noformat}

> CxfRsProducer is not thread safe
> --------------------------------
>
>                 Key: CAMEL-5469
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5469
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>    Affects Versions: 2.10.0
>         Environment: apache-maven-3.0
> tomcat 6.0.35
>            Reporter: Dumitru Pascu
>            Assignee: Willem Jiang
>            Priority: Major
>             Fix For: 2.11.0
>
>         Attachments: CamelRoute.java, 
> CxfRsProducerClientFactoryCacheTest.java, 
> CxfRsProducerClientFactoryCacheTest1.xml, camel-example-cxf-tomcat.zip
>
>
> The example is based on the camel-example-cxf-tomcat.
> Components:
> 1. Have a CXF rest web service configured in camel-config. 
> 2. Have a Camel CXF client cxf:rsClient used to call web service from point 1.
> 3. Have a Camel CXF server cxf:rsServer which acts as a proxy for service 
> from point 1 by passing inbount message towards client from point 2.
> Flow:
> 1. Service 3 receives message
> 2. Message is passed to component 2 (Camel cxf client)
> 3. Component 2 invokes service 1
> 4. Response received is transformed using a custom processor
> Problem:
> When having multiple requests in parallel, following error appears 
> (CxfRsProducer does not seem to be thread safe):
> {noformat}
> java.lang.RuntimeException: java.util.ConcurrentModificationException
>       at 
> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:217)[cxf-rt-frontend-jaxrs-2.6.1.jar:2.6.1]
>       at 
> org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeHttpClient(CxfRsProducer.java:100)[camel-cxf-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:87)[camel-cxf-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:115)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.syncInvoke(CxfRsInvoker.java:122)[camel-cxf-2.10.0.jar:2.10.0]
>       at 
> org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:60)[camel-cxf-2.10.0.jar:2.10.0]
>       at 
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)[cxf-api-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)[cxf-rt-frontend-jaxrs-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)[cxf-rt-frontend-jaxrs-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)[cxf-api-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)[cxf-api-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[cxf-api-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)[cxf-api-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:617)[servlet-api.jar:]
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)[cxf-rt-transports-http-2.6.1.jar:2.6.1]
>       at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)[catalina.jar:6.0.35]
>       at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)[catalina.jar:6.0.35]
>       at 
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)[tomcat-coyote.jar:6.0.35]
>       at 
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)[tomcat-coyote.jar:6.0.35]
>       at 
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)[tomcat-coyote.jar:6.0.35]
>       at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
> {noformat}
> Whole project is attached, including Jmeter JMX (which is under 
> \camel-example-cxf-tomcat\jmeter\ folder from the zip file).



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

Reply via email to