RFR: 8306308: (ch) Writer created by Channels::newWriter may lose data [v5]

Alan Bateman alanb at openjdk.org
Fri Oct 20 16:45:32 UTC 2023


On Fri, 20 Oct 2023 16:34:28 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> I think this is close to what you want here:
>> 
>>         try (ServerSocket ss = new ServerSocket();
>>              SocketChannel sc = SocketChannel.open()) {
>> 
>>             InetAddress lb = InetAddress.getLoopbackAddress();
>>             ss.bind(new InetSocketAddress(lb, 0));
>>             sc.connect(ss.getLocalSocketAddress());
>
> I had already committed f1b74f084cabbece4c7b19b9f404fddfa2e9b45d before I saw this comment, Should that be changed?

> I had already committed https://github.com/openjdk/jdk/commit/f1b74f084cabbece4c7b19b9f404fddfa2e9b45d before I saw this comment, Should that be changed?

Your change binds the connecting socket, it's the listener socket that should be bound to the loopback.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16207#discussion_r1367237231


More information about the nio-dev mailing list