commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Morten Hattesen (JIRA)" <>
Subject [jira] [Commented] (IO-357) Tailer: Interruption while sleeping is silently ignored
Date Wed, 21 Nov 2012 01:36:58 GMT


Morten Hattesen commented on IO-357:

That would definitely do the job.

The only minor issue would be that the calling thread would have no way of knowing that the
Tailer was  stopped by interruption, but I honestly don't see any situation where that would
cause a major issue at all.

It should be considered to also call {{listener.handle(e)}} prior to calling {{stop()}}, which
would at least  give the listener a chance to discover the interruption, and possibly perform
some logging etc.

> Tailer: Interruption while sleeping is silently ignored
> -------------------------------------------------------
>                 Key: IO-357
>                 URL:
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.4
>            Reporter: Morten Hattesen
> The implementation of 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.
> # 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

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:

View raw message