Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D58A1D172 for ; Tue, 17 Jul 2012 14:43:06 +0000 (UTC) Received: (qmail 46051 invoked by uid 500); 17 Jul 2012 14:43:06 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 45994 invoked by uid 500); 17 Jul 2012 14:43:06 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 45983 invoked by uid 99); 17 Jul 2012 14:43:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 14:43:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 14:43:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 400F32388ABB; Tue, 17 Jul 2012 14:42:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1362520 - /cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Date: Tue, 17 Jul 2012 14:42:46 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120717144246.400F32388ABB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Tue Jul 17 14:42:45 2012 New Revision: 1362520 URL: http://svn.apache.org/viewvc?rev=1362520&view=rev Log: Merged revisions 1360701 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes ........ r1360701 | dkulp | 2012-07-12 10:29:02 -0400 (Thu, 12 Jul 2012) | 19 lines Merged revisions 1360677 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes ........ r1360677 | dkulp | 2012-07-12 09:47:43 -0400 (Thu, 12 Jul 2012) | 11 lines Merged revisions 1360406 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1360406 | dkulp | 2012-07-11 17:15:48 -0400 (Wed, 11 Jul 2012) | 3 lines If another thread is working on adding threads, just return and let it handle it. ........ ........ ........ Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1362520&r1=1362519&r2=1362520&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java (original) +++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Tue Jul 17 14:42:45 2012 @@ -60,6 +60,7 @@ public class AutomaticWorkQueueImpl exte final int corePoolSize; final int maxPoolSize; final ReentrantLock mainLock; + final ReentrantLock addThreadLock = new ReentrantLock(); public AutomaticWorkQueueImpl() { this(DEFAULT_MAX_QUEUE_SIZE); @@ -382,21 +383,27 @@ public class AutomaticWorkQueueImpl exte super.execute(r); if (addWorkerMethod != null && !getQueue().isEmpty() - && getPoolSize() < maxPoolSize) { - mainLock.lock(); + && getPoolSize() < maxPoolSize + && addThreadLock.tryLock()) { + try { - int ps = this.getPoolSize(); - int sz = getQueue().size(); - int sz2 = this.getActiveCount(); + mainLock.lock(); + try { + int ps = this.getPoolSize(); + int sz = getQueue().size(); + int sz2 = this.getActiveCount(); - if ((sz + sz2) > ps) { - addWorkerMethod.setAccessible(true); - addWorkerMethod.invoke(this, addWorkerArgs); + if ((sz + sz2) > ps) { + addWorkerMethod.setAccessible(true); + addWorkerMethod.invoke(this, addWorkerArgs); + } + } catch (Exception ex) { + //ignore + } finally { + mainLock.unlock(); } - } catch (Exception ex) { - //ignore } finally { - mainLock.unlock(); + addThreadLock.unlock(); } } }