Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 82021200C35 for ; Sun, 12 Mar 2017 20:47:43 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 80B0B160B8A; Sun, 12 Mar 2017 19:47:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CDEE8160B87 for ; Sun, 12 Mar 2017 20:47:42 +0100 (CET) Received: (qmail 65629 invoked by uid 500); 12 Mar 2017 19:47:33 -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 62667 invoked by uid 99); 12 Mar 2017 19:47:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Mar 2017 19:47:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 97AE8F4B6F; Sun, 12 Mar 2017 19:47:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mattsicker@apache.org To: commits@commons.apache.org Date: Sun, 12 Mar 2017 19:47:58 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [28/50] [abbrv] commons-pool git commit: Simplify code a little archived-at: Sun, 12 Mar 2017 19:47:43 -0000 Simplify code a little git-svn-id: https://svn.apache.org/repos/asf/commons/proper/pool/trunk@1735259 13f79535-47bb-0310-9956-ffa450edef68 Project: http://git-wip-us.apache.org/repos/asf/commons-pool/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-pool/commit/9c75d18b Tree: http://git-wip-us.apache.org/repos/asf/commons-pool/tree/9c75d18b Diff: http://git-wip-us.apache.org/repos/asf/commons-pool/diff/9c75d18b Branch: refs/heads/master Commit: 9c75d18b8ca0c34d9a193e93b6ec435bb788c326 Parents: db15a29 Author: Mark Thomas Authored: Wed Mar 16 16:35:26 2016 +0000 Committer: Mark Thomas Committed: Wed Mar 16 16:35:26 2016 +0000 ---------------------------------------------------------------------- .../apache/commons/pool2/impl/GenericKeyedObjectPool.java | 8 +++++--- .../org/apache/commons/pool2/impl/GenericObjectPool.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-pool/blob/9c75d18b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java index 20281ee..82987da 100644 --- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java +++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java @@ -993,7 +993,10 @@ public class GenericKeyedObjectPool extends BaseGenericObjectPool * @throws Exception If the objection creation fails */ private PooledObject create(final K key) throws Exception { - final int maxTotalPerKeySave = getMaxTotalPerKey(); // Per key + int maxTotalPerKeySave = getMaxTotalPerKey(); // Per key + if (maxTotalPerKeySave < 0) { + maxTotalPerKeySave = Integer.MAX_VALUE; + } final int maxTotal = getMaxTotal(); // All keys final ObjectDeque objectDeque = poolMap.get(key); @@ -1020,8 +1023,7 @@ public class GenericKeyedObjectPool extends BaseGenericObjectPool final long newCreateCount = objectDeque.getCreateCount().incrementAndGet(); // Check against the per key limit - if (maxTotalPerKeySave > -1 && newCreateCount > maxTotalPerKeySave || - newCreateCount > Integer.MAX_VALUE) { + if (newCreateCount > maxTotalPerKeySave) { numTotal.decrementAndGet(); objectDeque.getCreateCount().decrementAndGet(); // POOL-303. There may be threads waiting on an object return that http://git-wip-us.apache.org/repos/asf/commons-pool/blob/9c75d18b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java index 7a3ee80..2aadb43 100644 --- a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java +++ b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java @@ -841,10 +841,12 @@ public class GenericObjectPool extends BaseGenericObjectPool * @throws Exception if the object factory's {@code makeObject} fails */ private PooledObject create() throws Exception { - final int localMaxTotal = getMaxTotal(); + int localMaxTotal = getMaxTotal(); + if (localMaxTotal < 0) { + localMaxTotal = Integer.MAX_VALUE; + } final long newCreateCount = createCount.incrementAndGet(); - if (localMaxTotal > -1 && newCreateCount > localMaxTotal || - newCreateCount > Integer.MAX_VALUE) { + if (newCreateCount > localMaxTotal) { createCount.decrementAndGet(); // POOL-303. There may be threads waiting on an object return that // isn't going to happen. Unblock them.