RFR: 8310426: (ch) Channels.newInputStream transferTo cleanup

Markus KARG duke at openjdk.org
Wed Jun 21 20:32:07 UTC 2023


On Tue, 20 Jun 2023 15:15:51 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> ChannelInputStream, the InputStream returned by Channels.newInputStream, implements the transferTo method with support for the cross product of many interesting underlying channels. It's getting a bit too unwieldy and can be simplified by introducing a FileChannelInputStream to wrap a FileChannel.

I am planning to provide optimizations for Channel-based Reader::transferTo in future, just like I did for InputStream::transferTo in the past. If we would have Channels::transfer(RBW, MBW) then I could simply reuse proven and trusted code. If we separate the code, then I have to provide (possibly several) new classes. I better understand and appreciate the merits of your new classes now thanks to you explanation, but it would be beneficial if the actual channel-to-channel algorithm could get reused.

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

PR Comment: https://git.openjdk.org/jdk/pull/14566#issuecomment-1601626871


More information about the nio-dev mailing list