RFR: 8265891: ChannelInputStream.transferTo() uses FileChannel.transferTo()

Markus KARG github.com+1701815+mkarg at openjdk.java.net
Fri Aug 20 06:22:27 UTC 2021


On Thu, 19 Aug 2021 18:25:39 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> SelectableChannel is an abstract class, not an interface so you can't extend both FileChannel and SelectableChannel. So when the source channel is a FileChannel then it should only be concerned with whether the target channel is a SelectableChannel or not. I think we can keep it very simple, along the lines of the method I pasted in above.

Silly me, you are right, it is an abstract class! Totally missed this!

> If you choose to include the case where the target is a SelectableChannel (and I have no objection to doing that) then the test needs to exercise that code. This means the test needs an input stream created on a source file/FileChannel, and an output stream created an channel that is WritableByteChannel & SelectableChannel. A Pipe.SinkChannel or a connected SocketChannel will do fine. If you choose to leave out selectable channels for the first PR then file -> file is okay, which I think is what your current test is doing.

Thanks a lot for the detailed explanation! I now better understood your concerns and will change the PR accordingly!

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

PR: https://git.openjdk.java.net/jdk/pull/5179


More information about the nio-dev mailing list