RFR: 8371718: (sc) Channels.new{Input, Output}Stream can allocate unbounded memory for a socket channel [v3]
Brian Burkhalter
bpb at openjdk.org
Tue Dec 9 18:43:30 UTC 2025
On Tue, 9 Dec 2025 16:54:17 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>>> Setting the limit twice per iteration is a bit confusing
>>
>> I actually made this change locally but decided against it. I'll take a second look.
>
>> In passing, the pre-existing throwing of RuntimeException should be re-examined at some point.
>
> For this case, FileOutputStream throws an IOException with message "Write error" and IOUtil.convertReturnVal throws an IOException with message "Read/write failed".
> if (n <= 0)
> throw new RuntimeException("no bytes written");
> pos += n;
> rem -= n;
This failed to update the buffer position in the loop. Fixed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28705#discussion_r2603886913
More information about the nio-dev
mailing list