cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Freeman Fang (JIRA)" <>
Subject [jira] [Commented] (CXF-3558) JaxWsProxyFactoryBean.create is not thread-safe
Date Tue, 31 May 2011 02:56:48 GMT


Freeman Fang commented on CXF-3558:

Hi Tomasz,

As Willem mentioned here, the proxy itself is actually thread safe already, do you really
need create multiple proxies per thread, I can't image a necessary scenario for it, could
you please clarify your requirement?
Moreover, I don't think currently the way to create a proxy is thread safe by design, besides
the create method, we also have lots of other variable for ClientProxyFactoryBean like username/password/properties/bus/features/databinding
which can cause uncertain if you try to set those from different thread.

So the correct way is create only one proxy and use it in different thread.


> JaxWsProxyFactoryBean.create is not thread-safe
> -----------------------------------------------
>                 Key: CXF-3558
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime
>    Affects Versions: 2.4
>            Reporter: Tomasz Nurkiewicz
>            Assignee: Freeman Fang
>         Attachments: CXF-3558.txt
> While running {{JaxWsProxyFactoryBean.create}} concurrently I encountered the following
> {code}Caused by: java.util.ConcurrentModificationException
> 	at java.util.LinkedList$ListItr.checkForComodification(
> 	at java.util.LinkedList$
> 	at org.apache.cxf.service.factory.AbstractServiceFactoryBean.sendEvent(
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(
> 	at
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(
> 	at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(
> {code}
> Although not documented (?), {{org.apache.cxf.service.factory.ReflectionServiceFactoryBean#create}}
called somewhere during endpoint creation is {{synchronized}} which suggests whole {{create}}
is thread-safe, but apparently it's not.
> I managed to discover source of this problem. I captured two threads: one ({{pool-1-thread-4}})
entered synchronized {{ReflectionServiceFactoryBean#create}}, the second one ({{pool-1-thread-2}})
didn't made there yet but instead it calls {{AbstractServiceFactoryBean.setBus}} outside of
the {{synchronized}} block. This causes the {{org.apache.cxf.service.factory.AbstractServiceFactoryBean#listeners}}
to be updated, making the former thread being susceptible to {{ConcurrentModificationException}}.
Stack dumps attached.
> Please either fix concurrency issue (making {{listeners}} instance of {{java.util.concurrent.CopyOnWriteArrayList}}
might not be enough though) or document that {{JaxWsProxyFactoryBean.create}} is not thread-safe.

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message