Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BF8819C6B for ; Thu, 12 Apr 2012 20:05:32 +0000 (UTC) Received: (qmail 59666 invoked by uid 500); 12 Apr 2012 20:05:32 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 59620 invoked by uid 500); 12 Apr 2012 20:05:32 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 59613 invoked by uid 99); 12 Apr 2012 20:05:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 20:05:32 +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; Thu, 12 Apr 2012 20:05:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 077002388847 for ; Thu, 12 Apr 2012 20:05:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1325480 - in /commons/proper/pool/branches/1_5_RELEASE: ./ src/changes/changes.xml src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java src/java/org/apache/commons/pool/impl/GenericObjectPool.java Date: Thu, 12 Apr 2012 20:05:07 -0000 To: commits@commons.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120412200508.077002388847@eris.apache.org> Author: markt Date: Thu Apr 12 20:05:07 2012 New Revision: 1325480 URL: http://svn.apache.org/viewvc?rev=1325480&view=rev Log: POOL-212. If minIdle > maxIdle use maxIdle in place of minIdle Modified: commons/proper/pool/branches/1_5_RELEASE/ (props changed) commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Propchange: commons/proper/pool/branches/1_5_RELEASE/ ------------------------------------------------------------------------------ Merged /commons/proper/pool/branches/POOL_1_X:r1325476 Modified: commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml?rev=1325480&r1=1325479&r2=1325480&view=diff ============================================================================== --- commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml (original) +++ commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml Thu Apr 12 20:05:07 2012 @@ -25,6 +25,11 @@ Ensure the evictor thread runs with the same class loader that was in use when the pool was created to ensure that the factory class is visible. + + If a pool is configured with maxIdle < minIdle, ensure the evictor does + not create minIdle instances only to have them immediately destroyed by + using maxIdle for minIdle in this case. + Modified: commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1325480&r1=1325479&r2=1325480&view=diff ============================================================================== --- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (original) +++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java Thu Apr 12 20:05:07 2012 @@ -812,6 +812,10 @@ public class GenericKeyedObjectPool exte * timeBetweenEvictionRunsMillis > 0 and attempts to ensure * that each pool has the required minimum number of instances are only * made during idle object eviction runs. + *

+ * If the configured value of minIdle is greater than the configured value + * for maxIdle then the value of maxIdle will be used instead. + * * @param poolSize - The minimum size of the each keyed pool * @since Pool 1.3 * @see #getMinIdle @@ -827,12 +831,21 @@ public class GenericKeyedObjectPool exte * timeBetweenEvictionRunsMillis > 0 and attempts to ensure * that each pool has the required minimum number of instances are only * made during idle object eviction runs. + *

+ * If the configured value of minIdle is greater than the configured value + * for maxIdle then the value of maxIdle will be used instead. + * * @return minimum size of the each keyed pool * @since Pool 1.3 * @see #setTimeBetweenEvictionRunsMillis */ public int getMinIdle() { - return _minIdle; + int maxIdle = getMaxIdle(); + if (_minIdle > maxIdle) { + return maxIdle; + } else { + return _minIdle; + } } /** @@ -2064,7 +2077,7 @@ public class GenericKeyedObjectPool exte */ private void ensureMinIdle() throws Exception { //Check if should sustain the pool - if (_minIdle > 0) { + if (getMinIdle() > 0) { Object[] keysCopy; synchronized(this) { // Get the current set of keys Modified: commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1325480&r1=1325479&r2=1325480&view=diff ============================================================================== --- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java (original) +++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Thu Apr 12 20:05:07 2012 @@ -748,6 +748,9 @@ public class GenericObjectPool extends B * numActive + numIdle >= maxActive. * This setting has no effect if the idle object evictor is disabled * (i.e. if timeBetweenEvictionRunsMillis <= 0). + *

+ * If the configured value of minIdle is greater than the configured value + * for maxIdle then the value of maxIdle will be used instead. * * @param minIdle The minimum number of objects. * @see #getMinIdle @@ -764,12 +767,19 @@ public class GenericObjectPool extends B * Returns the minimum number of objects allowed in the pool * before the evictor thread (if active) spawns new objects. * (Note no objects are created when: numActive + numIdle >= maxActive) + *

+ * If the configured value of minIdle is greater than the configured value + * for maxIdle then the value of maxIdle will be used instead. * * @return The minimum number of objects. * @see #setMinIdle */ public synchronized int getMinIdle() { - return _minIdle; + if (_minIdle > _maxIdle) { + return _maxIdle; + } else { + return _minIdle; + } } /**