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

Chris Hegarty chegar999 at gmail.com
Mon Dec 19 15:54:04 UTC 2022


Hi Dawid,

On 19/12/2022 15:46, Dawid Weiss wrote:
>     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.

No disagreement. This is a bad bug. Once merged, I'll propose to 
backport, as appropriate.

 > 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 

Ah! Thanks for the explanation, it helps with my understanding of the 
potential impact of this bug.

> 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.

Lucky, or unlucky! ;-)  But seriously, thanks for reporting it.

-Chris.


More information about the net-dev mailing list