On Tue, 20 Dec 2022 22:01:14 GMT, Daniel Jeliński <djelin...@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

Reply via email to