commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject [28/50] [abbrv] commons-pool git commit: Simplify code a little
Date Sun, 12 Mar 2017 19:47:58 GMT
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 <markt@apache.org>
Authored: Wed Mar 16 16:35:26 2016 +0000
Committer: Mark Thomas <markt@apache.org>
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<K,T> extends BaseGenericObjectPool<T>
      * @throws Exception If the objection creation fails
      */
     private PooledObject<T> 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<T> objectDeque = poolMap.get(key);
@@ -1020,8 +1023,7 @@ public class GenericKeyedObjectPool<K,T> extends BaseGenericObjectPool<T>
         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<T> extends BaseGenericObjectPool<T>
      * @throws Exception if the object factory's {@code makeObject} fails
      */
     private PooledObject<T> 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.


Mime
View raw message