commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1132536 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java
Date Mon, 06 Jun 2011 07:27:15 GMT
Author: psteitz
Date: Mon Jun  6 07:27:15 2011
New Revision: 1132536

URL: http://svn.apache.org/viewvc?rev=1132536&view=rev
Log:
Fixed and restored test.  Test object class was not threadsafe.

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java?rev=1132536&r1=1132535&r2=1132536&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedObjectPool.java
Mon Jun  6 07:27:15 2011
@@ -18,6 +18,7 @@
 package org.apache.commons.dbcp2;
 
 import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -70,7 +71,6 @@ public class TestAbandonedObjectPool ext
     * 
     */
     public void testConcurrentInvalidation() throws Exception {
-        /** FIXME: re-enable when associated pool problem is resolved *****
         final int POOL_SIZE = 30;
         pool.setMaxActive(POOL_SIZE);
         pool.setMaxIdle(POOL_SIZE);
@@ -109,8 +109,7 @@ public class TestAbandonedObjectPool ext
         }
         
         // Now, the number of open connections should be 0
-        assertTrue("numActive should have been 0, was " + pool.getNumActive(), pool.getNumActive()
== 0);
-        */
+        assertTrue("numActive should have been 0, was " + pool.getNumIdle(), pool.getNumActive()
== 0);
     }
     
     class ConcurrentBorrower extends Thread {
@@ -164,12 +163,11 @@ class PooledTestObject extends Abandoned
     private boolean active = false;
     private int _hash = 0;
     private boolean _abandoned = false;
-
-    private static int hash = 1;
+    private static AtomicInteger hash = new AtomicInteger();
     
     public PooledTestObject(AbandonedConfig config) {
         super(config);
-        _hash = hash++;
+        _hash = hash.incrementAndGet();
     }
     
     public synchronized void setActive(boolean b) {



Mime
View raw message