RFR: 8371718: (sc) Channels.new{Input, Output}Stream can allocate unbounded memory for a socket channel
Alan Bateman
alanb at openjdk.org
Mon Dec 8 19:30:57 UTC 2025
On Mon, 8 Dec 2025 19:10:42 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Clamp read and write to 128k bytes.
src/java.base/share/classes/sun/nio/ch/ChannelOutputStream.java line 71:
> 69: ByteBuffer writeBuf = bb.remaining() <= MAX_ADAPTOR_BUFFER_SIZE
> 70: ? bb : bb.slice(bb.position(), MAX_ADAPTOR_BUFFER_SIZE);
> 71: int n = ch.write(writeBuf);
This just need to adjust the limit, no need for slice.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28705#discussion_r2599857802
More information about the nio-dev
mailing list