By bmargulies

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

A customer of ours complains that, sporadically, calls of ours to 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
at java.nio.channels.spi.AbstractInterruptibleChannel.end(


@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!…

Related Questions

Sponsored Content

26 Answered Questions

89 Answered Questions

34 Answered Questions

[SOLVED] Create ArrayList from array

49 Answered Questions

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

16 Answered Questions

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

27 Answered Questions

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

  • 2009-03-02 22:56:34
  • Malachi
  • 1091456 View
  • 1933 Score
  • 27 Answer
  • Tags:   java enums

55 Answered Questions

[SOLVED] How to create a memory leak 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
  • 643102 View
  • 6733 Score
  • 9 Answer
  • Tags:   java date timezone

58 Answered Questions

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

11 Answered Questions

Sponsored Content