Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3297

JettyClientEngine: elide buffering

    XMLWordPrintable

Details

    Description

      As originally implemented, the JettyClientEngine could not extract responses without buffering the entire response body, since the MessageBodyReader is sync only. Now, RESTEasy has an asynchronous Executor available to the engine.

      So, instead of buffering the full response, let's push the body reader to the async executor pool and feed it content as it becomes available. This should play well with the upcoming virtual threads support in the JVM. This also allows us to implement proper flow control: instead of buffering the whole response, we tell Jetty when we have consumed its buffers, so it will limit the amount of in-flight data.

      As an added bonus, the request content send is restructured so the content is also streamed out without buffering the entire request body in a ByteArrayOutputStream.

      In the best case, this should remove an entirely unnecessary byte[] copy of both request and response data.
      I have completed some light testing and will continue to run the code over the coming days to make sure there's no obvious problems.

      Attachments

        Activity

          People

            jperkins-rhn James Perkins
            jperkins-rhn James Perkins
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: