为什么我们在 Java 1.6 中从 FileChannel.map 得到 ClosedByInterruptException?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1161297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why are we getting ClosedByInterruptException from FileChannel.map in Java 1.6?
提问by bmargulies
A customer of ours complains that, sporadically, calls of ours to FileChannel.mapfail with a ClosedByInterruptException. The Javadocdoes not list this as a legitimate possibility. Does anyone know what might be going on here?
我们的一位客户抱怨说,我们的客户偶尔FileChannel.map会因为ClosedByInterruptException. 在Javadoc中没有列出这是一个合法的可能性。有谁知道这里会发生什么?
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)
采纳答案by cafebabe
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.
通道操作绑定到执行操作的线程。如果此线程中断,则由于 IO 安全问题,流/通道将关闭。
回答by bmargulies
The last comment contains the answer. There was a thread pool in use, and at shutdown interrupts were delivered.
最后一条评论包含答案。有一个线程池正在使用中,并在关闭时传递中断。

