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

Brian Burkhalter bpb at openjdk.org
Wed Oct 18 01:01:27 UTC 2023


On Tue, 17 Oct 2023 06:38:38 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> [...] so this PR has potential to make the code much simpler.

So simplified in 1d8a667c0160fe9d698773e6bbf8abc2b8ee2596.

> src/java.base/share/classes/java/nio/channels/Channels.java line 544:
> 
>> 542:     {
>> 543:         Objects.requireNonNull(ch, "ch");
>> 544:         return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
> 
> You could avoid one level of indirection by using `StreamEncoder.forOutputStreamWriter` instead of `new OutputStreamWriter` here. `OutputStreamWriter` is a pass-through wrapper for `StreamEncoder.forOutputStreamWriter` (except for [JDK-6856817](https://bugs.openjdk.org/browse/JDK-6856817) / dc93a924ee4d3b53f0271af577148f8a53eedb57, but that's another story)

So changed in c225b9fae846a673d8c372509aa90cd2ead8a3fd. Thanks.

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

PR Comment: https://git.openjdk.org/jdk/pull/16207#issuecomment-1767424639
PR Review Comment: https://git.openjdk.org/jdk/pull/16207#discussion_r1362967985


More information about the nio-dev mailing list