You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Morten Hattesen (JIRA)" <ji...@apache.org> on 2012/11/21 01:24:58 UTC

[jira] [Updated] (IO-357) Tailer: Interruption while sleeping is silently ignored

     [ https://issues.apache.org/jira/browse/IO-357?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Morten Hattesen updated IO-357:
-------------------------------

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

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

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.
# Rethrow the InterruptedException wrapped in a (subclass of) RuntimeException.
# Reassert the interrupted state of the thread by calling {{Thread.currentThread.interrupt()}}

For reference, please refer to these resources about handling thread interruption:
* http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
* Java Concurrency in Practice http://www.javaconcurrencyinpractice.com/

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

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

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 eliminate the catch clause. 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.
# Rethrow the InterruptedException wrapped in a (subclass of) RuntimeException.
# Reassert the interrupted state of the thread by calling {{Thread.currentThread.interrupt()}}



    
> Tailer: Interruption while sleeping is silently ignored
> -------------------------------------------------------
>
>                 Key: IO-357
>                 URL: https://issues.apache.org/jira/browse/IO-357
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.4
>            Reporter: Morten Hattesen
>
> The implementation of org.apache.commons.io.input.Tailer silently ignores interruptions while sleeping (in two places).
> Source snippet:
> {code}
> 360	                    try {
> 361	                        Thread.sleep(delayMillis);
> 362	                    } catch (InterruptedException e) {
> 363	                    }
> ...
> 425	                try {
> 426	                    Thread.sleep(delayMillis);
> 427	                } catch (InterruptedException e) {
> 428	                }
> {code}
> 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.
> # Rethrow the InterruptedException wrapped in a (subclass of) RuntimeException.
> # Reassert the interrupted state of the thread by calling {{Thread.currentThread.interrupt()}}
> For reference, please refer to these resources about handling thread interruption:
> * http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
> * Java Concurrency in Practice http://www.javaconcurrencyinpractice.com/

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira