Author: psteitz
Date: Sun Feb 22 15:53:50 2015
New Revision: 1661488

URL: http://svn.apache.org/r1661488
Log:
Tidy up test case for JIRA: POOL-287.

Modified:
    
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Modified: 
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: 
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1661488&r1=1661487&r2=1661488&view=diff
==============================================================================
--- 
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
 (original)
+++ 
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
 Sun Feb 22 15:53:50 2015
@@ -2152,10 +2152,10 @@ public class TestGenericKeyedObjectPool
      */
     @Test
     public void testReturnToHead() throws Exception {
-        SimpleFactory<String> factory = new SimpleFactory<String>();
+        final SimpleFactory<String> factory = new SimpleFactory<String>();
         factory.setValidateLatency(100);
         factory.setValid(true);  // Validation always succeeds
-        GenericKeyedObjectPool<String, String> pool = new 
GenericKeyedObjectPool<String, String>(factory);
+        final GenericKeyedObjectPool<String, String> pool = new 
GenericKeyedObjectPool<String, String>(factory);
         pool.setMaxWaitMillis(1000);
         pool.setTestWhileIdle(true);
         pool.setMaxTotalPerKey(2);
@@ -2173,8 +2173,11 @@ public class TestGenericKeyedObjectPool
         // At this point, one eviction run should have completed, visiting o1
         // and eviction cursor should be pointed at o2, which is the next 
offered instance
         Thread.sleep(250);         // Wait for evictor to start
-        pool.borrowObject("one");  // o2 is under eviction, so this will 
return o1
-        pool.borrowObject("one");  // Once validation completes, o2 should be 
offered
+        final String o1 = pool.borrowObject("one");  // o2 is under eviction, 
so this will return o1
+        final String o2 = pool.borrowObject("one");  // Once validation 
completes, o2 should be offered
+        pool.returnObject("one", o1);
+        pool.returnObject("one", o2);
+        pool.close();
     }
 
     private static class DummyFactory


Reply via email to