The implementation of org.apache.commons.io.input.Tailer silently ignores interruptions while sleeping (in two places).
This is an inappropriate behavior, since it prevents controlled shutdown by a container.
This may be rectified in one of these ways:
- Declare the method as "throws InterruptedException" and re-throw the InterruptedException, after possibly performing come cleanup, or removing the catch clause entirely. This will ensure that a thread interruption (possibly caused by the forced shutdown by a container) will cause processing to stop, and shutdown to proceed. Problem: Requires backwards incompatible change to method signature.
- Treat an interrupt as an alternate way of signalling the Tailer to stop, by calling stop() in the catch clause.
- Reassert the interrupted state of the thread by calling Thread.currentThread.interrupt() to be able to detect the interruption at a later stage.
For reference, please refer to these resources about handling thread interruption:
- Java Concurrency in Practice http://www.javaconcurrencyinpractice.com/