RFR: 8306308: (ch) Writer created by Channels::newWriter may lose data [v5]
Alan Bateman
alanb at openjdk.org
Fri Oct 20 16:24:42 UTC 2023
On Fri, 20 Oct 2023 10:24:22 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8306308: Add test
>
> 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());
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16207#discussion_r1367216253
More information about the nio-dev
mailing list