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


The following commit(s) were added to refs/heads/master by this push:
     new cbeeaa84 Use Map#computeIfAbsent() instead of manually operating on 
the Map
cbeeaa84 is described below

commit cbeeaa84172dbbc66772adaa7ec748cbbac7e69e
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Jul 7 09:06:39 2023 -0400

    Use Map#computeIfAbsent() instead of manually operating on the Map
---
 src/main/java/org/apache/commons/pool2/PoolUtils.java | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/pool2/PoolUtils.java 
b/src/main/java/org/apache/commons/pool2/PoolUtils.java
index f70280af..57324bd1 100644
--- a/src/main/java/org/apache/commons/pool2/PoolUtils.java
+++ b/src/main/java/org/apache/commons/pool2/PoolUtils.java
@@ -500,14 +500,9 @@ public final class PoolUtils {
          */
         @Override
         protected ErodingFactor getErodingFactor(final K key) {
-            ErodingFactor eFactor = factors.get(key);
-            // this may result in two ErodingFactors being created for a key
+            // This may result in two ErodingFactors being created for a key
             // since they are small and cheap this is okay.
-            if (eFactor == null) {
-                eFactor = new ErodingFactor(this.factor);
-                factors.put(key, eFactor);
-            }
-            return eFactor;
+            return factors.computeIfAbsent(key, k -> new 
ErodingFactor(this.factor));
         }
 
         /**

Reply via email to