RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes

Dawid Weiss dawid.weiss at gmail.com
Mon Dec 19 15:46:47 UTC 2022


> This is generally not an issue that would occur very frequently, since the
> `IOV_MAX` is commonly 1024 on Mac/Linux, and 16 on Windows. However, it is
> clearly a bug, and should be fixed.
>

The issue was actually very predictable (and frequent) on Windows... I
guess it'll depend on the use case. The big problem is that this bug can
result in a silent data corruption. Consider my scenario: a http server
produced a JSON response with a stream of objects inside. The stream was
flushed after each object (it's a different story why this was happening).
So something like this:

[
 { "key1": "value1" },
 { "key2": "value2" },
  ...
 { "keyN": "valueN" }
]

Because data flushes occurred regularly after each object (line, in this
case), HttpClient+ofFile subscriber would just miss a random part of the
response but the written JSON would parse and behave as if it were valid.
It is only a lucky coincidence that this was noticed at all.

Dawid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/net-dev/attachments/20221219/abd7dba6/attachment.htm>


More information about the net-dev mailing list