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

Chris Hegarty chegar at openjdk.org
Wed Dec 21 08:50:51 UTC 2022


On Tue, 20 Dec 2022 22:01:14 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> That being said, I think I'd implement the method as something like:
> 
> ```
>   do {
>      out.write(buffers);
>   } while (Utils.hasRemaining(buffers));
> ```
> 
> this addresses both the possible failure modes, and leaves the math out of the picture.

This addresses my primary concerns relating to the potential for a busy/infinite loop here - since it short-circuits a complete  iteration of the buffers when determining the loop condition, while still ensuring that all remaining data is written (and avoiding any potential buffer "fiddling" messing up the math).  Darn! I forgot about hasRemaining, nice!

Thanks for this concrete suggestion, accepted. I'm going to add @djelinski as a contributor.

@djelinski Would you mind running this latest branch through Mach5, just to ensure that everything is still ok.

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

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


More information about the net-dev mailing list