RFR: 8306308: (ch) Writer created by Channels::newWriter may lose data [v5]
Brian Burkhalter
bpb at openjdk.org
Fri Oct 20 16:37:59 UTC 2023
On Fri, 20 Oct 2023 16:22:10 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> test/jdk/java/nio/channels/Channels/NewWriter.java line 84:
>>
>>> 82: () -> {
>>> 83: try (ServerSocket ss = new ServerSocket(0);
>>> 84: SocketChannel cs = SocketChannel.open(new InetSocketAddress(ss.getLocalPort()))) {
>>
>> You probably should bind the SeverSocket to the loopback address to avoid interference from other machines.
>>
>> I assume this should be "sc" (for SocketChannel) rather than "cs". The naming of the test methods looks a bit strange too, did you mean both to have an uppercase character as the first character?
>
> 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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16207#discussion_r1367228369
More information about the nio-dev
mailing list