Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-357

[Tailer] InterruptedException while the thead is sleeping is silently ignored

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.5
    • Component/s: Streams/Writers
    • Labels:
      None

      Description

      The implementation of org.apache.commons.io.input.Tailer silently ignores interruptions while sleeping (in two places).

      Source snippet:

      360	                    try {
      361	                        Thread.sleep(delayMillis);
      362	                    } catch (InterruptedException e) {
      363	                    }
      ...
      425	                try {
      426	                    Thread.sleep(delayMillis);
      427	                } catch (InterruptedException e) {
      428	                }
      

      This is an inappropriate behavior, since it prevents controlled shutdown by a container.

      This may be rectified in one of these ways:

      1. 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.
      2. Treat an interrupt as an alternate way of signalling the Tailer to stop, by calling stop() in the catch clause.
      3. 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:

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mortenh Morten Hattesen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: