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

Alan Bateman alanb at openjdk.org
Fri Oct 20 10:27:41 UTC 2023


On Thu, 19 Oct 2023 23:46:03 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Change `Channels.newWriter` to return a `Writer` created by first wrapping the `WritableByteChannel` in an `OutputStream` using `Channels.newOutputStream` and then wrapping the result in an `OutputStreamWriter`. With this change in place, the problems reported in the issue do not occur.
>
> 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?

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

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


More information about the nio-dev mailing list