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

Chris Hegarty chegar at openjdk.org
Tue Dec 20 19:46:53 UTC 2022


On Tue, 20 Dec 2022 12:06:35 GMT, Dawid Weiss <dawid.weiss at gmail.com> wrote:

> ...
> Why can't it just spin-wait and let the IO subsystem handle buffer writes, whenever they're possible? I'd find an exception from that method surprising - even if the filesystem returns zero written bytes, for whatever reason, I don't think it's an exceptional situation - it follows the contract of that method and is a valid output to me; handle it like any other bytesWritten > 0?

It is acceptable for the gathering write to return zero bytes, and in some contexts it is acceptable to just unconditionally retry over and over, but the HTTP Client implementation is generally more pedantic than that, preferring to err on the side of caution. What is currently in this PR is a reasonable compromise, at the expense of a little more complexity in the code.

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

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


More information about the net-dev mailing list