RFR: 8305744: (ch) InputStream returned by Channels.newInputStream should have fast path for ReadbleByteChannel/WritableByteChannel [v3]

Markus KARG duke at openjdk.org
Sun Apr 9 13:43:38 UTC 2023


On Sat, 8 Apr 2023 06:48:22 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Putting the special casing for an output stream backed by a ChannelOutputStream in one place.
>
> src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 269:
> 
>> 267: 
>> 268:         // ReableByteChannel -> WritableByteChannel
>> 269:         if (out instanceof ChannelOutputStream cos) {
> 
> I think it might be better to change the code at L254 to:
> 
> 
>         if (out instanceof ChannelOutputStream cos) {
>             ReadableByteChannel rbc = ch;
>             WritableByteChannel wbc = cos.channel();
> 
>             // FileChannel -> WritableByteChannel
> 
>             // ...
>         }
> 
> 
> That puts the special casing for an output stream backed by a ChannelOutputStream in one place.

Agreed and done in 7039304d0ab75fdf7d400a3e8d0f60cd9d535ad6. Funny anecdote: Originally I had it this way but then modified it to simplify the review.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13387#discussion_r1161287874


More information about the nio-dev mailing list