RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes [v2]
Chris Hegarty
chegar at openjdk.org
Tue Dec 20 11:12:54 UTC 2022
On Tue, 20 Dec 2022 10:51:20 GMT, Dawid Weiss <duke at openjdk.org> wrote:
>> Well this has the potential of creating a busy loop since bytesWritten will not increase if zero is returned.
>
> I know that. But write should eventually make progress - even if it spins a few times. What's the point of having that JDK method explicitly state "may return 0" and then disregarding that as something that is an exceptional scenario? I don't see the consistency here... If it can return zero, fine - handle it by retrying. If this code falls into a spin loop and never makes progress - this would be a problem somewhere else (perhaps in the implementation of the file channel), not here.
I'm on the fence a little on this point. I really dislike the potential for a busy loop, but also don't want the added complication of retry/backoff in this loop. But really the latter is the right solution. lemme see how it looks.
-------------
PR: https://git.openjdk.org/jdk/pull/11722
More information about the net-dev
mailing list