Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are we getting ClosedByInterruptException from FileChannel.map in Java 1.6?

A customer of ours complains that, sporadically, calls of ours to FileChannel.map fail with a ClosedByInterruptException. The Javadoc does not list this as a legitimate possibility. Does anyone know what might be going on here?

Cause0: java.nio.channels.ClosedByInterruptException
Cause0-StackTrace:
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:772)
like image 841
bmargulies Avatar asked Jul 21 '09 19:07

bmargulies


2 Answers

Channel operations are bound to the thread doing the operations. If this thread is interrupted, the stream / channel is closed due to IO safety issues.

like image 100
cafebabe Avatar answered Nov 06 '22 03:11

cafebabe


The last comment contains the answer. There was a thread pool in use, and at shutdown interrupts were delivered.

like image 39
bmargulies Avatar answered Nov 06 '22 03:11

bmargulies