On Tue, 20 Dec 2022 14:53:11 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:
> 
>   fix catch

Thanks for the explanation, Chris. I remain somewhat unconvinced about the 
special treatment for http client code here but perhaps I'm overly sensitive... 
If you care to read on then my concern is that at the API surface the 
programmer sees "write the response to a path" functionality - plain and 
simple. A disk-full or an I/O exception due to a hardware problem is easy to 
understand but an IOException("zero bytes written") showing up in the logs 
somewhere would probably leave me severely confused as to what actually 
happened. To me, the API the http client code is actually using to write the 
response bytes is an implementation detail. If it's using a low-level API that 
can return odd zero written bytes, it should be able to cope with that and not 
just panic and throw exceptions to user-space.

So, to summarize, I just hope this zero-written-bytes exception scenario is not 
something I'll ever see in reality. :)

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

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

Reply via email to