RFR: 8371718: (sc) Channels.new{Input, Output}Stream can allocate unbounded memory for a socket channel [v3]

Alan Bateman alanb at openjdk.org
Tue Dec 9 17:50:05 UTC 2025


On Tue, 9 Dec 2025 16:30:08 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> test/jdk/java/nio/channels/Channels/SocketChannelStreams.java line 76:
>> 
>>> 74:      * Test writing and reading an array of bytes.
>>> 75:      */
>>> 76:     public void testWriteRead() throws Exception {
>> 
>> I don't think this test is useful as there are a lot of tests here that do this. I think the test for this change will use a custom ByteChannel implementation that fails if called with a buffer that are >128k remaining.
>
>> I don't think this test is useful as there are a lot of tests here that do this.
> 
> It was intended to verify loops in an alternative implementation I wrote last week so can be reverted I think.

I think we can add a new test with test channel implementations that throw if invoked with remaining > 128k. That would at least test the changes to ChannelInputStream and ChannelOutputStream.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28705#discussion_r2603676782


More information about the nio-dev mailing list