-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
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.