Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3558

JaxWsProxyFactoryBean.create is not thread-safe

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4
    • 2.4.1, 2.3.5
    • JAX-WS Runtime
    • None
    • Moderate

    Description

      While running JaxWsProxyFactoryBean.create concurrently I encountered the following exception:

      Caused by: java.util.ConcurrentModificationException
      	at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761)
      	at java.util.LinkedList$ListItr.next(LinkedList.java:696)
      	at org.apache.cxf.service.factory.AbstractServiceFactoryBean.sendEvent(AbstractServiceFactoryBean.java:71)
      	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:238)
      	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
      	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
      	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
      	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:152)
      	at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
      

      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.

      Attachments

        1. CXF-3558.txt
          3 kB
          Tomasz Nurkiewicz

        Activity

          No work has yet been logged on this issue.

          People

            ffang Freeman Yue Fang
            nurkiewicz Tomasz Nurkiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: