commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1628064 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
Date Sun, 28 Sep 2014 11:22:06 GMT
Author: ecki
Date: Sun Sep 28 11:22:05 2014
New Revision: 1628064

URL: http://svn.apache.org/r1628064
Log:
Fix loop condition for POOL-277 (will fail under concurrency), some more tests, whitespace
fix

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java?rev=1628064&r1=1628063&r2=1628064&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
Sun Sep 28 11:22:05 2014
@@ -882,7 +882,7 @@ public abstract class BaseGenericObjectP
             if (currentMax >= waitTime) {
                 break;
             }
-        } while (maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime));
+        } while (!maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime));
     }
 
     /**

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java?rev=1628064&r1=1628063&r2=1628064&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
Sun Sep 28 11:22:05 2014
@@ -46,13 +46,26 @@ public class TestBaseGenericObjectPool {
     
     @Test
     public void testBorrowWaitStatistics() {
-    	DefaultPooledObject<String> p = (DefaultPooledObject<String>) factory.makeObject();
-    	pool.updateStatsBorrow(p, 10);
-    	pool.updateStatsBorrow(p, 20);
-    	pool.updateStatsBorrow(p, 20);
-    	pool.updateStatsBorrow(p, 30);
-    	Assert.assertEquals(20, pool.getMeanBorrowWaitTimeMillis(), Double.MIN_VALUE);
-    	Assert.assertEquals(30, pool.getMaxBorrowWaitTimeMillis(), 0);
+        DefaultPooledObject<String> p = (DefaultPooledObject<String>) factory.makeObject();
+        pool.updateStatsBorrow(p, 10);
+        pool.updateStatsBorrow(p, 20);
+        pool.updateStatsBorrow(p, 20);
+        pool.updateStatsBorrow(p, 30);
+        Assert.assertEquals(20, pool.getMeanBorrowWaitTimeMillis(), Double.MIN_VALUE);
+        Assert.assertEquals(30, pool.getMaxBorrowWaitTimeMillis(), 0);
+    }
+
+    public void testBorrowWaitStatisticsMax() {
+        DefaultPooledObject<String> p = (DefaultPooledObject<String>) factory.makeObject();
+        Assert.assertEquals(0, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE);
+        pool.updateStatsBorrow(p, 0);
+        Assert.assertEquals(0, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE);
+        pool.updateStatsBorrow(p, 20);
+        Assert.assertEquals(20, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE);
+        pool.updateStatsBorrow(p, 20);
+        Assert.assertEquals(20, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE);
+        pool.updateStatsBorrow(p, 10);
+        Assert.assertEquals(20, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE);
     }
     
     @Test



Mime
View raw message