On Tue, 20 Dec 2022 10:33:29 GMT, Chris Hegarty <che...@openjdk.org> wrote:

>> The implementation of `BodySubscribers.ofFile` does not correctly handle the 
>> case of a short gathering write. The write should be retried until all the 
>> bytes have been written to the underlying file.
>> 
>> 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.
>
> Chris Hegarty has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   review comments: 1) remove MAX_INT restriction, and 2) check 0 write

src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java 
line 291:

> 289:                     long n = out.write(buffers);
> 290:                     if (n <= 0) {
> 291:                         throw new IOException("zero bytes written");

"Returns: The number of bytes written, possibly zero"

Sorry for being dumb, but why is the returned zero bytes treated as an error? 
If I were to write a fuzzifier for that class, it'd be my first thing on the to 
do list to randomly return zero bytes - if the contract allows it, it should be 
handled gracefully.

-------------

PR: https://git.openjdk.org/jdk/pull/11722

Reply via email to