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

HttpConduit should flush output stream ahead of closing connections when HttpClient is autocloseable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.5, 3.6.4
    • 4.1.0, 3.6.5, 4.0.6
    • JAX-RS
    • None
    • Unknown

    Description

      HttpConduit should flush output stream ahead of closing connections when HttpClient is autocloseable.

      When running WebClient in a load test (single host) we'll observe low throughput.

      When we adjust the HttpConduit to flush output stream ahead of connection close, we observe significant throughput improvement. 

      The key issue being addressed here is ephemeral port usage. Once all available ports are in use, the clients are unable to send more messages.
      Controlling ephemeral port usage means the client can more often send messages to the server-side.

      Given this appears to affect just autocloseable HttpClient, we select to flush the output stead only when the JVM provides the autocloseable HttpClient variety.
       

      AbstractConduit:
      finally {
          OutputStream os = msg.getContent(OutputStream.class);
          // Java 21 may hang on close, we flush stream to help close them out.
          if (os != null && AutoCloseable.class.isAssignableFrom(HttpClient.class))

      {.          os.flush();     }

      super.close(msg);
      }
       

      Attachments

        Issue Links

          Activity

            People

              jgoodyear Jamie Mark Goodyear
              jgoodyear Jamie Mark Goodyear
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: