You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/06/03 16:18:50 UTC

[commons-pool] branch master updated (2510ee9 -> 9d596d9)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git.


    from 2510ee9  Fix generics warnings, remove unused exceptions, don't override @AfterEach method name, remove unused imports.
     new 928840e  Format nits.
     new 9d596d9  Inline single use local variable.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/pool2/impl/BaseGenericObjectPool.java     |  3 +--
 .../commons/pool2/impl/GenericKeyedObjectPool.java    | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

[commons-pool] 01/02: Format nits.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git

commit 928840e3f088a25ee6b963f82e41f87a4bad82be
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 3 11:38:33 2021 -0400

    Format nits.
---
 .../commons/pool2/impl/GenericKeyedObjectPool.java    | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

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 2cc62a7..ed5f206 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
@@ -1340,9 +1340,6 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
         return ac != null ? ac.getRemoveAbandonedTimeoutDuration() : DEFAULT_REMOVE_ABANDONED_TIMEOUT;
     }
 
-
-    //--- inner classes ----------------------------------------------
-
     /**
      * Checks to see if there are any threads currently waiting to borrow
      * objects but are blocked waiting for more objects to become available.
@@ -1382,6 +1379,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
     public void invalidateObject(final K key, final T obj) throws Exception {
         invalidateObject(key, obj, DestroyMode.NORMAL);
     }
+
     /**
      * {@inheritDoc}
      * <p>
@@ -1400,13 +1398,10 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
      */
     @Override
     public void invalidateObject(final K key, final T obj, final DestroyMode mode) throws Exception {
-
         final ObjectDeque<T> objectDeque = poolMap.get(key);
-
         final PooledObject<T> p = objectDeque.getAllObjects().get(new IdentityWrapper<>(obj));
         if (p == null) {
-            throw new IllegalStateException(
-                    "Object not currently part of this pool");
+            throw new IllegalStateException("Object not currently part of this pool");
         }
         synchronized (p) {
             if (p.getState() != PooledObjectState.INVALID) {
@@ -1417,6 +1412,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
             addObject(key);
         }
     }
+
     /**
      * Gets whether or not abandoned object removal is configured for this pool.
      *
@@ -1428,6 +1424,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
     public boolean isAbandonedConfig() {
         return abandonedConfig != null;
     }
+
     /**
      * Provides information on all the objects in the pool, both idle (waiting
      * to be borrowed) and active (currently borrowed).
@@ -1458,6 +1455,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
         }
         return result;
     }
+
     /**
      * Registers a key for pool control and ensures that
      * {@link #getMinIdlePerKey()} idle instances are created.
@@ -1473,6 +1471,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
         }
         ensureMinIdle(key);
     }
+
     /**
      * Register the use of a key by an object.
      * <p>
@@ -1660,6 +1659,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
             updateStatsReturn(activeTime);
         }
     }
+
     /**
      * Attempt to create one new instance to serve from the most heavily
      * loaded pool that can add a new instance.
@@ -1709,6 +1709,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
             }
         }
     }
+
     /**
      * Sets the abandoned object removal configuration.
      *
@@ -1732,6 +1733,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
             this.abandonedConfig.setRequireFullStackTrace(abandonedConfig.getRequireFullStackTrace());
         }
     }
+
     /**
      * Sets the configuration.
      *
@@ -1746,6 +1748,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
         setMaxTotal(conf.getMaxTotal());
         setMinIdlePerKey(conf.getMinIdlePerKey());
     }
+
     /**
      * Sets the cap on the number of "idle" instances per key in the pool.
      * If maxIdlePerKey is set too low on heavily loaded systems it is possible
@@ -1765,6 +1768,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
     public void setMaxIdlePerKey(final int maxIdlePerKey) {
         this.maxIdlePerKey = maxIdlePerKey;
     }
+
     /**
      * Sets the limit on the number of object instances allocated by the pool
      * (checked out or idle), per key. When the limit is reached, the sub-pool
@@ -1777,6 +1781,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
     public void setMaxTotalPerKey(final int maxTotalPerKey) {
         this.maxTotalPerKey = maxTotalPerKey;
     }
+
     /**
      * Sets the target for the minimum number of idle objects to maintain in
      * each of the keyed sub-pools. This setting only has an effect if it is

[commons-pool] 02/02: Inline single use local variable.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git

commit 9d596d9f1bd9b1b0a9fe07a92e882eaf5d13a6b6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 3 12:18:46 2021 -0400

    Inline single use local variable.
---
 src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index 7c2f258..c241123 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -980,8 +980,7 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
      */
     protected void markReturningState(final PooledObject<T> pooledObject) {
         synchronized(pooledObject) {
-            final PooledObjectState state = pooledObject.getState();
-            if (state != PooledObjectState.ALLOCATED) {
+            if (pooledObject.getState() != PooledObjectState.ALLOCATED) {
                 throw new IllegalStateException(
                         "Object has already been returned to this pool or is invalid");
             }