|Re: [jgit-dev] nio exception|
On Tue, Mar 6, 2012 at 05:16, Markus Duft <markus.duft@xxxxxxxxxx> wrote: > i keep getting things like this in various places all over on linux: > > Caused by: java.nio.channels.ClosedByInterruptException > at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:201) > at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:335) > at org.eclipse.jgit.util.IO.readFully(IO.java:140) > at org.eclipse.jgit.util.IO.readFully(IO.java:78) > at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:130) > at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:88) > at org.eclipse.jgit.api.ReflogCommand.call(ReflogCommand.java:92) > ... 47 more NIO shouldn't be used in a multi-threaded program that might use Thread.interrupt(): http://blog.spearce.org/2010/05/dont-assume-you-know-whats-best.html A long time ago I switched the pack file access code away from NIO because of this problem. I didn't realize we were still using NIO for the ReflogReader. Ick. > any thoughts? i happened to get this for reads of the .git/config file previously sporadically since 1.1, I didn't realize the config file reader used NIO either. I thought that was a simple FileInputStream. > but now it also happened for the stash feature (which is new for me - i fetched from the repos today). Ick. JGit as a library really cannot rely on using NIO, or needs to be more careful where it is used. If the embedding application sends an interrupt to a thread that JGit has doing file IO using NIO, JGit needs to be prepared for the file being closed as the interrupt is delivered. One can argue that at least delivering the interrupt instead of doing the requested IO operation is the right behavior, as its likely the user has requested the operation to cancel (IIRC Eclipse sends an interrupt on the cancel/stop button in a progress bar) so doing more IO is maybe not a good idea. But closing the file handle automatically like NIO does is really evil.
Back to the top