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

Modifications to JAX-WS client request context leak the thread scope

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.7
    • Fix Version/s: 3.1.12, 3.0.14, 3.2.0
    • Component/s: Core
    • Labels:
      None
    • Environment:

      java version "1.7.0_80"

      Description

      As documented in this page the request context can be made thread local (Thus, anything set there will affect requests on other threads.), but
      I observed that even after having set the property thread.local.request.context it arrives sometimes that some modifications to the request context leak the thread scope, leading potentially to unpredictable behaviors.

      Digging in the code I found that the reason is the following.

      The class org.apache.cxf.endpoint.ClientImpl stores the request context entries in a map called currentRequestContext. After property thread.local.request.context is set to true a call to getRequestContext() triggers the creation of another map of type org.apache.cxf.endpoint.ClientImpl.EchoContext which is associated to the current thread (the mapping is kept in the requestContext map). This should guarantee the per thread isolation.
      The EchoContext is initialized with the entries of the shared map, and as its name suggests modifications are echoed back to the shared map. The problem is that when accessing the request context for the first time in a thread all the modifications done on other threads do affect the current thread even after "thread.local.request.context" is set to true, due to the initialization of the thread local map with shared one.

        Attachments

        1. CXF-6782_reproducer.tar.gz
          3 kB
          Iacopo Rozzo

          Activity

            People

            • Assignee:
              ffang Freeman Yue Fang
              Reporter:
              iacopo Iacopo Rozzo
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: