6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
Rémi Forax
forax at univ-mlv.fr
Sun Nov 7 07:24:44 PST 2010
Le 07/11/2010 13:14, Alan Bateman a écrit :
>
> I've been talking to Dag Wanvik (Derby/Java DB project) about some
> issues that they are seeing when threads doing I/O with a FileChannel
> are interrupted. They periodically see the channel being "silently
> closed" and also spurious ClosedByInterruptExceptions thrown by other
> threads doing I/O that are not interrupted. As it turns out there is a
> small rat's nest that has always been there. The following changes fix
> these issues so that ClosedByInterruptException is consistently
> thrown, and only by the thread that is interrupted. We may need to
> follow this up with a spec clarification for the case that a thread is
> interrupted at just around the time that an I/O completes.
>
> http://cr.openjdk.java.net/~alanb/6979009/webrev/
>
> Thanks,
> Alan.
There is another bug, closeLock is not final in
AbstractInterruptibleChannel.
Also in AbstractSelector and in AbstractInterruptibleChannel, this code:
if (Thread.currentThread().isInterrupted())
interruptor.interrupt(Thread.currentThread());
can be changed to:
Thread current = Thread.currentThread();
if (current.isInterrupted())
interruptor.interrupt(current);
to avoid to call Threa.currentThread twice.
About the patch, I'm not sure to fully understand it.
Rémi
More information about the nio-dev
mailing list