Skip to content
Advertisement

What Happens when a thread doesn’t throw an exception?

I notice, in this javadoc, https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html that an UncaughtExceptionHandler is used for when an exception occurs but is not caught. But, will that thread fail quietly? I guess so, because it is going about its business asynchronously, but I’m investigating a related issue with one of our processes, and am surprised at only being aware of this now, 10+ years into my career.

Advertisement

Answer

I finally got to the bottom of my specific problem. It was due to shoddy error handling, allowing the thread to fail quietly:

JavaScript

In doing “some stuff”, the application hit an OutOfMemoryError, which is not, strictly seaking, an Exception. Changing the above to catch(Throwable t), solved it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement