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

ASF GitHub Bot commented on CAMEL-12252:
----------------------------------------

aldettinger commented on issue #2218: fix CAMEL-12252 and add test case for it
URL: https://github.com/apache/camel/pull/2218#issuecomment-367832813
 
 
   In the case at hand, each call to 
[createJAXRSClientFactoryBean(...)](https://github.com/apache/camel/blob/d577c2b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L861)
 always return the same client factory bean instance but with an overridden 
address. We end up in a situation where 
[ClientFactoryBeanCache.get(address)](https://github.com/apache/camel/blob/d577c2b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L855)
 could serve a factory bean with another address than requested.
   
   The `createJAXRSClientFactoryBean(...)` implementation was tweaked when [the 
rsClient scope changed to 
prototype](https://issues.apache.org/jira/browse/CAMEL-4648). But now, we have 
a single client factory bean since [the SpringRsEndpoint became a 
singleton](https://issues.apache.org/jira/browse/CAMEL-9176).
   
   Keeping in mind thread safety, I would explore how to change 
[newJAXRSClientFactoryBean(...)`](https://github.com/apache/camel/blob/f8b6d5b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java#L62)
 in order to make the cache keep references to immutable client factory 
bean**s**.
   
   Does it make sense ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Dynamic setting the DESTINATION_OVERRIDE_URL doesn't work on CXFRS producer
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-12252
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12252
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxfrs
>    Affects Versions: 2.17.0, 2.18.5, 2.19.4, 2.20.2
>         Environment: Java 8
>            Reporter: Xilai Dai
>            Priority: Major
>
> Given the sample MyProcessor, setting the DESTINATION_OVERRIDE_URL 
> dynamically during the invoke:
> {code}
> public void process(Exchange exchange) throws Exception {
>     String env = (String)exchange.getIn().getHeader("Environnement");
>     if (env.equalsIgnoreCase("DEV")) {
>         exchange.getIn().setHeader(exchange.DESTINATION_OVERRIDE_URL,
>             "http://esbdev11.local:8080/server1/metaServlet";);
>     } else {
>         exchange.getIn().setHeader(exchange.DESTINATION_OVERRIDE_URL,
>             "http://esblab11.local:8080/server2/metaServlet";);
>     }
> }
> {code}
> Given the sample Route:
> {code}
>         from("cxfrs:bean:MyREST")
>         .process(new HeaderProcessor())
>         .setHeader("Environnement")
>         .simple("${header.http_query[env][0]}")
>         .process(new MyProcessor())
>         .setHeader(org.apache.camel.Exchange.HTTP_METHOD, constant("GET"))
>         .setHeader(org.apache.camel.Exchange.ACCEPT_CONTENT_TYPE, 
> constant("*/*"))
>         .setHeader(org.apache.camel.Exchange.HTTP_PATH, constant("/"))
>         .to("cxfrs:bean:restClient?maxClientCacheSize=5");
> {code}
> Send request to cxfrs:bean:MyREST with different http header "dev", then the 
> cxfrs:bean:restClient always make call to the last setting Address.
> (Only it works as expected when setting maxClientCacheSize=0 on the 
> cxfrs:bean:restClient)
> There is no this issue on Camel 2.16.x, but start problem from Camel 2.17.x 
> and later versions. Investigations show that the CxfRsEndpoint becoming 
> Singleton after CAMEL-9628, that explain why the last Address setting always 
> applied.



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

Reply via email to