FileChannel implements InterruptibleChannel, help or hindrance?

Robert Muir rcmuir at gmail.com
Thu Mar 1 03:42:02 UTC 2018


On Wed, Feb 28, 2018 at 1:00 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> As we all know here, FileChannel implements InterruptibleChannel so it's
> asynchronously closeable and interrupting threads doing I/O operations on a
> file channel cause it to be closed.
>
> I've never been comfortable with the FileChannel being closed by
> Thread.interrupt and I'm wondering whether it would be worth providing a way
> for file I/O operations to not being interruptible.

It causes problems with apache lucene too: the file in question may
have been deleted (merged away) and so by closing it, its gone for
good: searching at that point-in-time is now impossible... we can't
reopen the file. Currently we give users a big warning not to use
Thread.interrupt/Future.cancel for that reason.


More information about the nio-dev mailing list