By bmargulies


2009-07-21 19:36:47 8 Comments

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)

2 comments

@bmargulies 2009-09-12 22:02:30

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

@cafebabe 2009-07-21 20:02:03

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.

@bmargulies 2009-07-21 20:18:48

What sort of operations result in such an interrupt? If I wanted to code a test case, what would I have it do? Why can a thread be interrupted in the middle of mapping a file? And what about Claire?

@cafebabe 2009-07-21 21:46:01

If the application is multi-threaded, you should look for #interrupt()-calls that might interrupt the thread doing the IO operations on the channel. If this is a web-application or some other kind of managed environment, where thread management isn't up to your application (like a Servlet / EJB Container), you should look for thread-safety violations. Another place to look is when the application is shutting down or when thread pooling is used (Servlet/EJB Container!). Then be aware of dynamic management of the pool size! java.sun.com/javase/6/docs/api/java/lang/…

Related Questions

Sponsored Content

55 Answered Questions

[SOLVED] Creating a memory leak with Java

58 Answered Questions

[SOLVED] How do I read / convert an InputStream into a String in Java?

35 Answered Questions

[SOLVED] Create ArrayList from array

83 Answered Questions

[SOLVED] Is Java "pass-by-reference" or "pass-by-value"?

22 Answered Questions

47 Answered Questions

[SOLVED] Does a finally block always get executed in Java?

9 Answered Questions

[SOLVED] Why is subtracting these two times (in 1927) giving a strange result?

  • 2011-07-27 08:15:58
  • Freewind
  • 615995 View
  • 6537 Score
  • 9 Answer
  • Tags:   java date timezone

11 Answered Questions

26 Answered Questions

[SOLVED] How to get an enum value from a string value in Java?

  • 2009-03-02 22:56:34
  • Malachi
  • 1033399 View
  • 1860 Score
  • 26 Answer
  • Tags:   java enums

16 Answered Questions

[SOLVED] Why is char[] preferred over String for passwords?

Sponsored Content