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/05/27 14:29:39 UTC

[commons-pool] branch master updated: Replace explicit with <> (#82)

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 b579982  Replace explicit with <> (#82)
b579982 is described below

commit b57998214fe9c91b29806b8cb743d0097a519be7
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Thu May 27 16:29:34 2021 +0200

    Replace explicit with <> (#82)
---
 src/main/java/org/apache/commons/pool2/PoolUtils.java          |  2 +-
 .../org/apache/commons/pool2/impl/GenericKeyedObjectPool.java  |  2 +-
 .../java/org/apache/commons/pool2/impl/GenericObjectPool.java  |  2 +-
 .../apache/commons/pool2/impl/SecurityManagerCallStack.java    |  2 +-
 .../java/org/apache/commons/pool2/VisitTrackerFactory.java     |  2 +-
 .../commons/pool2/impl/TestAbandonedKeyedObjectPool.java       | 10 +++++-----
 .../org/apache/commons/pool2/impl/TestAbandonedObjectPool.java | 10 +++++-----
 .../apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java |  2 +-
 .../apache/commons/pool2/impl/TestGenericKeyedObjectPool.java  | 10 +++++-----
 .../org/apache/commons/pool2/impl/TestGenericObjectPool.java   | 10 +++++-----
 10 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/apache/commons/pool2/PoolUtils.java b/src/main/java/org/apache/commons/pool2/PoolUtils.java
index ac1ca5f..64c7f2c 100644
--- a/src/main/java/org/apache/commons/pool2/PoolUtils.java
+++ b/src/main/java/org/apache/commons/pool2/PoolUtils.java
@@ -479,7 +479,7 @@ public final class PoolUtils {
         private final float factor;
 
         /** Map of ErodingFactor instances keyed on pool keys */
-        private final Map<K, ErodingFactor> factors = Collections.synchronizedMap(new HashMap<K, ErodingFactor>());
+        private final Map<K, ErodingFactor> factors = Collections.synchronizedMap(new HashMap<>());
 
         /**
          * Creates a new ErordingPerKeyKeyedObjectPool decorating the given keyed
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 fce6d1c..cd4819a 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
@@ -246,7 +246,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
      * @param factory the factory to be used to create entries
      */
     public GenericKeyedObjectPool(final KeyedPooledObjectFactory<K, T> factory) {
-        this(factory, new GenericKeyedObjectPoolConfig<T>());
+        this(factory, new GenericKeyedObjectPoolConfig<>());
     }
 
     /**
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 bf008a2..01b352a 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
@@ -133,7 +133,7 @@ public class GenericObjectPool<T> extends BaseGenericObjectPool<T>
      *                used by this pool
      */
     public GenericObjectPool(final PooledObjectFactory<T> factory) {
-        this(factory, new GenericObjectPoolConfig<T>());
+        this(factory, new GenericObjectPoolConfig<>());
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java b/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java
index 6225d4e..a47bb90 100644
--- a/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java
+++ b/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java
@@ -49,7 +49,7 @@ public class SecurityManagerCallStack implements CallStack {
             final Class<?>[] classes = getClassContext();
             final List<WeakReference<Class<?>>> stack = new ArrayList<>(classes.length);
             for (final Class<?> klass : classes) {
-                stack.add(new WeakReference<Class<?>>(klass));
+                stack.add(new WeakReference<>(klass));
             }
             return stack;
         }
diff --git a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
index 12e7288..fd2844b 100644
--- a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
+++ b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
@@ -52,7 +52,7 @@ public class VisitTrackerFactory<K>
 
     @Override
     public PooledObject<VisitTracker<K>> makeObject() {
-        return new DefaultPooledObject<>(new VisitTracker<K>(nextId++));
+        return new DefaultPooledObject<>(new VisitTracker<>(nextId++));
     }
 
     @Override
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java
index b609f33..7a38855 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java
@@ -155,7 +155,7 @@ public class TestAbandonedKeyedObjectPool {
 
         pool = new GenericKeyedObjectPool<>(
                new SimpleFactory(),
-               new GenericKeyedObjectPoolConfig<PooledTestObject>(),
+               new GenericKeyedObjectPoolConfig<>(),
                abandonedConfig);
     }
 
@@ -201,7 +201,7 @@ public class TestAbandonedKeyedObjectPool {
         pool = new GenericKeyedObjectPool<>(
                 // destroys take 200 ms
                 new SimpleFactory(200, 0),
-                new GenericKeyedObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+                new GenericKeyedObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
@@ -232,7 +232,7 @@ public class TestAbandonedKeyedObjectPool {
         pool.close();  // Unregister pool created by setup
         pool = new GenericKeyedObjectPool<>(
                 new SimpleFactory(200, 0),
-                new GenericKeyedObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+                new GenericKeyedObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
@@ -309,7 +309,7 @@ public class TestAbandonedKeyedObjectPool {
         pool = new GenericKeyedObjectPool<>(
              // validate takes 1 second
              new SimpleFactory(0, 0),
-             new GenericKeyedObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+             new GenericKeyedObjectPoolConfig<>(), abandonedConfig);
         pool.setTimeBetweenEvictionRuns(Duration.ofMillis(50));
         // Borrow an object, wait long enough for it to be abandoned
         final PooledTestObject obj = pool.borrowObject(0);
@@ -343,7 +343,7 @@ public class TestAbandonedKeyedObjectPool {
         pool = new GenericKeyedObjectPool<>(
              // validate takes 1 second
              new SimpleFactory(0, 1000),
-             new GenericKeyedObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+             new GenericKeyedObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
index b300251..e042d8d 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
@@ -221,7 +221,7 @@ public class TestAbandonedObjectPool {
 
         pool = new GenericObjectPool<>(
                new SimpleFactory(),
-               new GenericObjectPoolConfig<PooledTestObject>(),
+               new GenericObjectPoolConfig<>(),
                abandonedConfig);
     }
 
@@ -267,7 +267,7 @@ public class TestAbandonedObjectPool {
         pool = new GenericObjectPool<>(
                 // destroys take 200 ms
                 new SimpleFactory(200, 0),
-                new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+                new GenericObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
@@ -298,7 +298,7 @@ public class TestAbandonedObjectPool {
         pool.close();  // Unregister pool created by setup
         pool = new GenericObjectPool<>(
                 new SimpleFactory(200, 0),
-                new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+                new GenericObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
@@ -375,7 +375,7 @@ public class TestAbandonedObjectPool {
         pool = new GenericObjectPool<>(
              // validate takes 1 second
              new SimpleFactory(0, 0),
-             new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+             new GenericObjectPoolConfig<>(), abandonedConfig);
         pool.setTimeBetweenEvictionRuns(Duration.ofMillis(50));
         // Borrow an object, wait long enough for it to be abandoned
         final PooledTestObject obj = pool.borrowObject();
@@ -409,7 +409,7 @@ public class TestAbandonedObjectPool {
         pool = new GenericObjectPool<>(
              // validate takes 1 second
              new SimpleFactory(0, 1000),
-             new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
+             new GenericObjectPoolConfig<>(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
         pool.setBlockWhenExhausted(false);
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java
index bdf5c69..2da2316 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java
@@ -35,7 +35,7 @@ public class TestDefaultPooledObjectInfo {
         abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND);
         abandonedConfig.setLogAbandoned(true);
         try (final GenericObjectPool<String> pool = new GenericObjectPool<>(new SimpleFactory(),
-                new GenericObjectPoolConfig<String>(), abandonedConfig)) {
+                new GenericObjectPoolConfig<>(), abandonedConfig)) {
 
             pool.borrowObject();
             // pool.returnObject(s1); // Object not returned, causes abandoned object created exception
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 37503ce..1d02a15 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -1063,7 +1063,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
         // Give makeObject a little latency
         factory.setMakeLatency(200);
         try (final GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(factory,
-                new GenericKeyedObjectPoolConfig<String>())) {
+                new GenericKeyedObjectPoolConfig<>())) {
             final String s = pool.borrowObject("one");
             // First borrow waits on create, so wait time should be at least 200 ms
             // Allow 100ms error in clock times
@@ -1264,7 +1264,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
     public void testEqualsIndiscernible() throws Exception {
         final HashSetFactory factory = new HashSetFactory();
         try (final GenericKeyedObjectPool<String, HashSet<String>> pool = new GenericKeyedObjectPool<>(factory,
-                new GenericKeyedObjectPoolConfig<HashSet<String>>())) {
+                new GenericKeyedObjectPoolConfig<>())) {
             final HashSet<String> s1 = pool.borrowObject("a");
             final HashSet<String> s2 = pool.borrowObject("a");
             pool.returnObject("a", s1);
@@ -1435,7 +1435,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
 
         // Introduce latency between when evictor starts looking at an instance and when
         // it decides to destroy it
-        gkoPool.setEvictionPolicy(new SlowEvictionPolicy<String>(1000));
+        gkoPool.setEvictionPolicy(new SlowEvictionPolicy<>(1000));
 
         // Borrow an instance
         final String val = gkoPool.borrowObject("foo");
@@ -2223,7 +2223,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
     public void testMutable() throws Exception {
         final HashSetFactory factory = new HashSetFactory();
         try (final GenericKeyedObjectPool<String, HashSet<String>> pool = new GenericKeyedObjectPool<>(factory,
-                new GenericKeyedObjectPoolConfig<HashSet<String>>())) {
+                new GenericKeyedObjectPoolConfig<>())) {
             final HashSet<String> s1 = pool.borrowObject("a");
             final HashSet<String> s2 = pool.borrowObject("a");
             s1.add("One");
@@ -2296,7 +2296,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
 
     @Test
     public void testReturnObjectThrowsIllegalStateException() {
-        try (final GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(new SimpleFactory<String>())) {
+        try (final GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(new SimpleFactory<>())) {
             assertThrows(IllegalStateException.class,
                     () ->  pool.returnObject("Foo", "Bar"));
         }
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
index 0cc6e70..7ae7863 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -1103,7 +1103,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
         final SimpleFactory factory = new SimpleFactory();
         // Give makeObject a little latency
         factory.setMakeLatency(200);
-        try (final GenericObjectPool<String> pool = new GenericObjectPool<>(factory, new GenericObjectPoolConfig<String>())) {
+        try (final GenericObjectPool<String> pool = new GenericObjectPool<>(factory, new GenericObjectPoolConfig<>())) {
             final String s = pool.borrowObject();
             // First borrow waits on create, so wait time should be at least 200 ms
             // Allow 100ms error in clock times
@@ -1326,7 +1326,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
     public void testEqualsIndiscernible() throws Exception {
         final HashSetFactory factory = new HashSetFactory();
         try (final GenericObjectPool<HashSet<String>> pool = new GenericObjectPool<>(factory,
-                new GenericObjectPoolConfig<HashSet<String>>())) {
+                new GenericObjectPoolConfig<>())) {
             final HashSet<String> s1 = pool.borrowObject();
             final HashSet<String> s2 = pool.borrowObject();
             pool.returnObject(s1);
@@ -1564,7 +1564,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
             // expected
         }
 
-        genericObjectPool.setEvictionPolicy(new TestEvictionPolicy<String>());
+        genericObjectPool.setEvictionPolicy(new TestEvictionPolicy<>());
         assertEquals(TestEvictionPolicy.class.getName(), genericObjectPool.getEvictionPolicyClassName());
 
         genericObjectPool.setEvictionPolicyClassName(TestEvictionPolicy.class.getName());
@@ -2404,7 +2404,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
     // POOL-248
     @Test
     public void testMultipleReturnOfSameObject() throws Exception {
-        try (final GenericObjectPool<String> pool = new GenericObjectPool<>(simpleFactory, new GenericObjectPoolConfig<String>())) {
+        try (final GenericObjectPool<String> pool = new GenericObjectPool<>(simpleFactory, new GenericObjectPoolConfig<>())) {
 
             assertEquals(0, pool.getNumActive());
             assertEquals(0, pool.getNumIdle());
@@ -2437,7 +2437,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
     public void testMutable() throws Exception {
         final HashSetFactory factory = new HashSetFactory();
         try (final GenericObjectPool<HashSet<String>> pool = new GenericObjectPool<>(factory,
-                new GenericObjectPoolConfig<HashSet<String>>())) {
+                new GenericObjectPoolConfig<>())) {
             final HashSet<String> s1 = pool.borrowObject();
             final HashSet<String> s2 = pool.borrowObject();
             s1.add("One");