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

Alan Bateman alanb at openjdk.java.net
Sun Nov 21 15:16:08 UTC 2021


On Sun, 21 Nov 2021 15:11:55 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> I sketched a possibly solution in https://github.com/openjdk/jdk/pull/5179/commits/26ed670be318669edf1ef9a7101c1136273f2b82, but looking at the PipeImpl internals I doubt that *all* file descriptors actually get closed. To me it feels like this being actually a design flaw of PipeImpl: If one side of a pipe was never actually claimed then it should not keep a descriptor open. So IMHO the final solution would be to file a PR for PipeImpl which either defers opening of the file descriptors until they are claimed (which I doubt would be easily possible), or which cleans up both sides if as soon as one side is closed and the other side never got claimed (which is my personal preference).
>
>> I sketched a possibly solution in [26ed670](https://github.com/openjdk/jdk/commit/26ed670be318669edf1ef9a7101c1136273f2b82), but looking at the PipeImpl internals I doubt that _all_ file descriptors actually get closed. To me it feels like this being actually a design flaw of PipeImpl: 
> 
> A Pipe creates a pair of channels. If you change to something the following then it will fix the issue:
> 
> 
> Pipe pipe = Pipe.open();
> try {
>     :
> } finally {
>     pipe.source().close();
>     pipe.sink().close();
> }

BTW: Would it possible to sync up your loom, it looks like hasn't been updated for some time.

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

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


More information about the nio-dev mailing list