cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ranadeep.sharma@gmail.com" <ranadeep.sha...@gmail.com>
Subject CXF client for JaxWS proxy NOT thread-safe
Date Wed, 06 Jul 2016 13:38:43 GMT
Hi,I have a overridden factory for JaxWS proxy clients, as shown below. I
created this class as per the  CXF FAQs
<http://cxf.apache.org/faq.html#FAQ%2DAreJAX%2DWSclientproxiesthreadsafe%3F> 
.                                                    public class
TSafeJaxWsProxyFactoryBean extends JaxWsProxyFactoryBean {    public
TSafeJaxWsProxyFactoryBean() {        super();    }    public
TSafeJaxWsProxyFactoryBean(ClientFactoryBean fact) {        super(fact);   
}    @Override    protected ClientProxy clientClientProxy(Client c) {       
ClientProxy clientProxy = super.clientClientProxy(c);       
clientProxy.getRequestContext().put("thread.local.request.context", "true");       
return clientProxy;    }}In my application, I have 2 methods that use the
proxy created by the above factory. One method - getSessionInfo() populates
the BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the RequestContext before
the service call. Another method - startSession() just calls service without
populating above property.public class SessionManagerWrapperImpl {    public
SessionInfo startSession() {        ...        Map<String, Object>
requestContext = ((BindingProvider)      
sessionManagerService).getRequestContext();       
if(requestContext.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {           
requestContext.remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);        }       
...        // Make service call using 'sessionManagerService'        ...   
}        public SessionInfo getSessionInfo(String sessionId) {       
((BindingProvider) sessionManagerService).getRequestContext()               
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUri + ";jsessionid="
+ sessionId);                SessionInfo result =
sessionManagerService.getSessionInfo(sessionId);    }}Now, I am getting into
a situation where RequestContext is already having the mentioned property
for the thread processing startSession(). This is not expected, since CXF
documentation claims the explained usage to be thread-safe. Please let me
know if my understanding and implementation is correct. If not, please share
on what should be corrected. However, if my usage is correct, is there a
possible bug in CXF?



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-for-JaxWS-proxy-NOT-thread-safe-tp5770148.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message