Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4716

Threading issue in CommonsHTTPTransportSender when different messages use different HTTP versions or transfer encoding settings

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.2
    • 1.6.0
    • transports
    • None

    Description

      There is a threading issue in the CommonsHTTPTransportSender.writeMessageWithCommons() method where it determines what HTTP version to use when sending the message and whether the chunked transfer encoding should be used. The 'chunked' and 'httpVersion' member variables are set when this transport sender is constructed, but are then overridden as every message is sent if that message defines a property explicitly enabling the chunked encoding, or setting the HTTP version. However, as multiple threads may be active in this code simultaneously, it is very possible that the wrong combination of parameters will be used for a particular message. In addition, as soon as one message sets these values explicitly, the default values are changed for all subsequent messages.

      In the current trunk (r919960) from line 392:

      if (messageContext.getProperty(HTTPConstants.CHUNKED) != null) {
                      chunked = JavaUtils.isTrueExplicitly(messageContext
                              .getProperty(HTTPConstants.CHUNKED));
                  }
      
                  if (messageContext.getProperty(HTTPConstants.HTTP_PROTOCOL_VERSION) != null) {
                      httpVersion = (String) messageContext
                              .getProperty(HTTPConstants.HTTP_PROTOCOL_VERSION);
                  }
                  // Following order needed to be preserved because,
                  // HTTP/1.0 does not support chunk encoding
                  sender.setChunked(chunked);
                  sender.setHttpVersion(httpVersion);
                  sender.setFormat(format);
      

      This should be changed to use local variables for the http version and chunked encoding value, and retrieve this either from the message property or from the member variables if the message property is not set. The member variables for these settings should be regarded as immutable after init() has been called.

      Attachments

        Activity

          People

            veithen Andreas Veithen
            davebryant Dave Bryant
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: