Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 59884 invoked from network); 18 Jul 2008 03:53:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 03:53:23 -0000 Received: (qmail 96965 invoked by uid 500); 18 Jul 2008 03:53:22 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 96889 invoked by uid 500); 18 Jul 2008 03:53:22 -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 96878 invoked by uid 99); 18 Jul 2008 03:53:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 20:53:22 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 03:52:37 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C7823234C172 for ; Thu, 17 Jul 2008 20:52:31 -0700 (PDT) Message-ID: <1110369879.1216353151816.JavaMail.jira@brutus> Date: Thu, 17 Jul 2008 20:52:31 -0700 (PDT) From: "jochen (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (POOL-102) Thread waiting forever for borrowObject() cannot be interrupted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/POOL-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614628#action_12614628 ] jochen commented on POOL-102: ----------------------------- Steitz, It seems the Revision #549729 doesn't work. we met the issue on the HTTP threads being response to concurrent 40 users, which made the connection pool was exhausted and all of HTTP threads waiting on GenericObjectPool.borrowObject happened. Given the commons pool v2.0 doesn't come out, I got the v1.4 and was pleased to see the bug fixes list - Allowed blocked threads in GenericObjectPool borrowObject to be interrupted. Issue: POOL-102. But unfortunately it didn't fix our issue when I replaced the v1.4 with v1.3. HTTP threads were still waiting for GenericObjectPool.borrowObject. is it any solution to solve it out or any workaround exists? many thanks. > Thread waiting forever for borrowObject() cannot be interrupted > --------------------------------------------------------------- > > Key: POOL-102 > URL: https://issues.apache.org/jira/browse/POOL-102 > Project: Commons Pool > Issue Type: Bug > Affects Versions: 1.1, 1.2, 1.3 > Reporter: John Sumsion > Priority: Minor > Fix For: 2.0 > > > In the following GenericObjectPool snippet inside borrowObject(), InterruptedException is caught and ignored. > case WHEN_EXHAUSTED_BLOCK: > try { > if(_maxWait <= 0) { > wait(); > } else { > wait(_maxWait); > } > } catch(InterruptedException e) { > // ignored > } > There are two problems here: > 1) a thread waiting forever to get an object out of the pool will NEVER terminate, even if interrupted > 2) even if you put a "throw e" in, it will still be wrong because the thread's interrupted status is not preserved > This will cause cancellation problems for threads that are inside borrowObject() that want to terminate early ONLY if they are interrupted. > For example, if a borrow-and-wait-forever was running on an pooled executor thread in Java 1.5 and the executor service tried to cancel a task and that task had early-termination logic in it that checked interrupted status to terminate early, the task would never be cancelled. > For us, this is minor because we are on a Tomcat request thread that has to wait for this resource to continue, but for others that have pools of stuff that are being used by time-bound tasks, it's inconvenient to write code that waits for what ends up being arbitrary time periods for a wait. It would be easier to just say wait forever and allow interruption by someone else who is watching me. > Suggestion: make the code read like this: > case WHEN_EXHAUSTED_BLOCK: > try { > if(_maxWait <= 0) { > wait(); > } else { > wait(_maxWait); > } > } catch(InterruptedException e) { > Thread.currentThread().interrupt(); > throw e; > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.