Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0089BD917 for ; Wed, 21 Nov 2012 14:48:03 +0000 (UTC) Received: (qmail 21874 invoked by uid 500); 21 Nov 2012 14:48:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 21627 invoked by uid 500); 21 Nov 2012 14:47:59 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 21598 invoked by uid 99); 21 Nov 2012 14:47:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Nov 2012 14:47:58 +0000 Date: Wed, 21 Nov 2012 14:47:58 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: <616503989.12421.1353509278877.JavaMail.jiratomcat@arcas> In-Reply-To: <494203849.9945.1353455218769.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (IO-357) Tailer: Interruption while sleeping is silently ignored MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/IO-357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502017#comment-13502017 ] Sebb commented on IO-357: ------------------------- AFAICT there's no point calling stop outside the run loop, because the flag won't be checked. Also InterruptedException is an instance of Exception; no point in having a separate catch unless the code is different. So in fact the only change required would be to remove the catch blocks after Thread.sleep(). > 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. > # 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: > * 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