RFR: 8276779: (ch) InputStream returned by Channels.newInputStream should have fast path for SelectableChannels

Markus KARG duke at openjdk.java.net
Sun Nov 7 11:59:38 UTC 2021


On Sun, 7 Nov 2021 09:07:31 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> > @AlanBateman Kindly requesting review. :-)
> 
> The implementation change looks correct, it's as we discussed a few months ago: InputStream::transferTo needs to throw IllegalBlockingModeException when the source is an input stream backed by a FileChannel and the output stream is backed by a channel configured non-blocking.
> 
> While not a change to existing behavior, I'm mulling over whether we should clarify the specification of Channels.newInputStream. The current spec is:
> 
> "The read methods of the resulting stream will throw an IllegalBlockingModeException if invoked while the underlying channel is in non-blocking mode. "
> 
> We can expand this to "The read and transferTo methods ...".
> 
> We could also add "The transferTo method will also throw an IllegalBlockingModeException if invoked to transfer bytes to an output stream that writes to an underlying channel in non-blocking mode".
> 
> I'm not saying we have to update the API docs as part of this PR, I'm just pointing out that the existing spec wasn't updated when InputStream.transferTo was added, it probably should have been.

I would be happy to extend it in that way you proposed. Shall I do that?

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

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


More information about the nio-dev mailing list