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 2023/07/08 13:16:00 UTC
[commons-pool] branch master updated: Use modern Map API
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 18c1c99a Use modern Map API
18c1c99a is described below
commit 18c1c99ae9c3f97463708004b48d3d6b9799573f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 8 09:15:56 2023 -0400
Use modern Map API
---
.../apache/commons/pool2/impl/TestGenericKeyedObjectPool.java | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
index 4da07c18..57e37f6a 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -299,14 +299,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
@Override
public Object create(final Object key) {
- int counter = 0;
- final AtomicInteger Counter = map.get(key);
- if(null != Counter) {
- counter = Counter.incrementAndGet();
- } else {
- map.put(key, new AtomicInteger(0));
- counter = 0;
- }
+ int counter = map.computeIfAbsent(key, k -> new AtomicInteger(-1)).incrementAndGet();
return String.valueOf(key) + String.valueOf(counter);
}