RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes
Chris Hegarty
chegar at openjdk.org
Mon Dec 19 17:13:48 UTC 2022
On Mon, 19 Dec 2022 15:55:24 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
> Hey @ChrisHegarty glad to see you back :-) The proposed changes look reasonable. I will run them in the CI and approve if the tests come back clean.
Thanks @dfuch.
> I am a little puzzled by the description of the issue however as AFAIR the SocketTube will not produce a list that contains more than three ByteBuffers. So unless I'm mistaken the 1024 limit in one onNext() call should never be reached (at least when invoked by the HttpClient stack).
If the server sends the response as chunked, and say 1 byte of response body at a time, then several of these small chunks are effectively merged (by the kernel) into a single packet. On the receiving side, the HTTP Client can receive these in say even one byte buffer that contains several hundreds or even thousands of these chunks. This gets passed to the chunked response handler that parses them and creates a List of byte buffers, one for each small chunk, so there can be many many of these that eventually get sent the response subscriber.
I managed to intermittently reproduce this on my Mac, by hacking on the test - not pretty. I guess the test could be updated to try to provoke this with the HTTP Client, but it doesn't seem worth it, if we accept that it just needs to be fixed.
-------------
PR: https://git.openjdk.org/jdk/pull/11722
More information about the net-dev
mailing list