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

Data Race in org/apache/cxf/transport/http/HTTPConduit.prepare

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.1.3, 2.7.18, 3.0.7
    • Component/s: Transports
    • Labels:
      None
    • Environment:

      windows jdk 1.8

    • Estimated Complexity:
      Unknown

      Description

      When using the demo.hw.server.HelloWorld client from different threads a data race occurs in org/apache/cxf/transport/http/HTTPConduit.prepare:

      if (this.authSupplier == null)

      { this.authSupplier = createAuthSupplier(effectiveAuthPolicy.getAuthorizationType()); }

      I would suggest to make the field authSupplier volatile.

      Here is my Test client:
      public class TestCxfClient extends MultiThreadedOneInstanceTemplate {

      private static final QName SERVICE_NAME
      = new QName("http://server.hw.demo/", "HelloWorld");
      private static final QName PORT_NAME
      = new QName("http://server.hw.demo/", "HelloWorldPort");

      private final HelloWorld hw;

      public TestCxfClient(HelloWorld hw)

      { super(); this.hw = hw; }

      public void exec()

      { System.out.println(hw.sayHi("World")); }

      public static void main(String[] args) throws Exception

      { Service service = Service.create(SERVICE_NAME); // Endpoint Address String endpointAddress = "http://localhost:8080/java_first_jaxws/services/hello_world"; // If web service deployed on Tomcat (either standalone or embedded) // as described in sample README, endpoint should be changed to: // String endpointAddress = "http://localhost:8080/java_first_jaxws/services/hello_world"; // Add a port to the Service service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); HelloWorld hw = service.getPort(HelloWorld.class); (new TestCxfClient(hw)).test(); }

      }

      public abstract class MultiThreadedOneInstanceTemplate implements Runnable {

      private final AtomicInteger threadCount = new AtomicInteger();

      public void test() throws Exception
      {
      for(int i = 0; i < 2 ;i++)

      { Thread thread = new Thread(this, "Thread " + i); this.threadCount.incrementAndGet(); thread.start(); }

      while( this.threadCount.get() > 0 )

      { Thread.sleep(1000); }

      Thread.sleep(10 * 1000);
      }

      public void run()

      { exec(); threadCount.decrementAndGet(); }

      protected abstract void exec();

      }

      Data Race was found by http://vmlens.com

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              ThomasKrieger Thomas Krieger
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: