commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-pool git commit: [POOL-332] ObjectPool and KeyedObject pool should extend Closeable. Cleaning up tests by managing pools with try-with-resource blocks. More to do.
Date Wed, 01 Nov 2017 18:19:37 GMT
Repository: commons-pool
Updated Branches:
  refs/heads/master c5309f13a -> 5736b0ad1


[POOL-332] ObjectPool and KeyedObject pool should extend Closeable.
Cleaning up tests by managing pools with try-with-resource blocks.
More to do.

Project: http://git-wip-us.apache.org/repos/asf/commons-pool/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-pool/commit/5736b0ad
Tree: http://git-wip-us.apache.org/repos/asf/commons-pool/tree/5736b0ad
Diff: http://git-wip-us.apache.org/repos/asf/commons-pool/diff/5736b0ad

Branch: refs/heads/master
Commit: 5736b0ad12c2e2ad84d2fcbcfa1ce2a4f4ecbc60
Parents: c5309f1
Author: Gary Gregory <ggregory@apache.org>
Authored: Wed Nov 1 12:19:35 2017 -0600
Committer: Gary Gregory <ggregory@apache.org>
Committed: Wed Nov 1 12:19:35 2017 -0600

----------------------------------------------------------------------
 .../org/apache/commons/pool2/TestPoolUtils.java | 49 +++++++++++---------
 1 file changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-pool/blob/5736b0ad/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
index b253297..1316a32 100644
--- a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
+++ b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
@@ -557,19 +557,21 @@ public class TestPoolUtils {
 
     @Test
     public void testErodingObjectPoolDefaultFactor() {
-        @SuppressWarnings("unchecked")
-        final ObjectPool<Object> internalPool = createProxy(ObjectPool.class, new InvocationHandler()
{
+        try (@SuppressWarnings("unchecked")
+            final ObjectPool<Object> internalPool = createProxy(ObjectPool.class, new
InvocationHandler() {
+                
             @Override
             public Object invoke(final Object arg0, final Method arg1, final Object[] arg2)
throws Throwable {
                 return null;
             }
-        });
-        final ObjectPool<Object> pool = PoolUtils.erodingPool(internalPool);
-        final String expectedToString = "ErodingObjectPool{factor=ErodingFactor{factor=1.0,
idleHighWaterMark=1}, pool="
-                + internalPool + "}";
-        // The factor is not exposed, but will be printed in the toString() method
-        // In this case since we didn't pass one, the default 1.0f will be printed
-        assertEquals(expectedToString, pool.toString());
+        })) {
+            final ObjectPool<Object> pool = PoolUtils.erodingPool(internalPool);
+            final String expectedToString = "ErodingObjectPool{factor=ErodingFactor{factor=1.0,
idleHighWaterMark=1}, pool="
+                    + internalPool + "}";
+            // The factor is not exposed, but will be printed in the toString() method
+            // In this case since we didn't pass one, the default 1.0f will be printed
+            assertEquals(expectedToString, pool.toString());
+        }
     }
 
     @Test
@@ -682,20 +684,21 @@ public class TestPoolUtils {
 
     @Test
     public void testErodingPoolKeyedObjectPoolDefaultFactor() {
-        @SuppressWarnings("unchecked")
-        final
-        KeyedObjectPool<Object, Object> internalPool = createProxy(KeyedObjectPool.class,
new InvocationHandler() {
-            @Override
-            public Object invoke(final Object arg0, final Method arg1, final Object[] arg2)
-                    throws Throwable {
-                return null;
-            }
-        });
-        final KeyedObjectPool<Object, Object> pool = PoolUtils.erodingPool(internalPool);
-        final String expectedToString = "ErodingKeyedObjectPool{factor=ErodingFactor{factor=1.0,
idleHighWaterMark=1}, keyedPool=" + internalPool + "}";
-        // The factor is not exposed, but will be printed in the toString() method
-        // In this case since we didn't pass one, the default 1.0f will be printed
-        assertEquals(expectedToString, pool.toString());
+        try (@SuppressWarnings("unchecked")
+        final KeyedObjectPool<Object, Object> internalPool = createProxy(KeyedObjectPool.class,
+                new InvocationHandler() {
+                    @Override
+                    public Object invoke(final Object arg0, final Method arg1, final Object[]
arg2) throws Throwable {
+                        return null;
+                    }
+                })) {
+            final KeyedObjectPool<Object, Object> pool = PoolUtils.erodingPool(internalPool);
+            final String expectedToString = "ErodingKeyedObjectPool{factor=ErodingFactor{factor=1.0,
idleHighWaterMark=1}, keyedPool="
+                    + internalPool + "}";
+            // The factor is not exposed, but will be printed in the toString() method
+            // In this case since we didn't pass one, the default 1.0f will be printed
+            assertEquals(expectedToString, pool.toString());
+        }
     }
 
     @Test


Mime
View raw message