As part of a larger application, I set up a Spring Batch job that is made up by just a chunk oriented tasklet: reader, processor and writer. The job is not run in the main thread.
Occasionally the tasklet code throws an OutOfMemoryError. So, I set the thread's UncaughtExceptionHandler to be able to react to such errors, simply terminating the application.
But the OutOfMemoryError never reaches the thread's UncaughtExceptionHandler. I would say that the OutOfMemoryError is "swallowed", probably by AbstractStep, even if I'm not sure. RepeatTemplate has for sure a role. It could be able to inform some RepeatListeners about the OutOfMemoryError but no listeners are registered by default, and it seems it is not possible to register any of them through the usual tag in the taskled definition.
Anyhow, what happens is that even after an OutOfMemoryError, the JVM keeps on running, because the OoME is swallowed. This is not nice because it does not make explicit that the application has actually crashed.
So, do you have any advice on how I can prevent Spring Batch to swallow such kind of Errors and have the possibility to handle them ?
Obviously we're working also on fixing the OoME, but I think that it would be safe if the JVM simply crashes in case of Errors.
I'm using Spring Batch 3.0.1.