You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/01/08 13:30:58 UTC

svn commit: r897188 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java

Author: sebb
Date: Fri Jan  8 12:30:50 2010
New Revision: 897188

URL: http://svn.apache.org/viewvc?rev=897188&view=rev
Log:
Still trying to debug Continuum failures:
- Don't allow successful threads to loop if we are expecting a failure
This should make it easier to understand the debug output,
The first thread failure should stop all other threads, and this should happen
before the first successful thread completes its hold time.

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

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java?rev=897188&r1=897187&r2=897188&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java Fri Jan  8 12:30:50 2010
@@ -696,12 +696,11 @@
                     }
                 };
                 for (int i = 0; i < pts.length; i++) {
-                    (pts[i] = new PoolTest(threadGroup, holdTime)).start();
+                    // If we are expecting an error, don't allow successful threads to loop
+                    (pts[i] = new PoolTest(threadGroup, holdTime, expectError)).start();
                 }
 
-                long t1 = System.currentTimeMillis();
                 Thread.sleep(100L); // Wait for long enough to allow threads to start
-                long t2 = System.currentTimeMillis();
 
                 for (int i = 0; i < pts.length; i++) {
                     pts[i].stop();
@@ -732,7 +731,7 @@
                 long time = System.currentTimeMillis() - startTime;
                 System.out.println("Multithread test time = " + time
                         + " ms. Threads: " + pts.length
-                        + ". Hold time: " + holdTime + ". Held: " + (t2-t1)
+                        + ". Hold time: " + holdTime
                         + ". Maxwait: " + maxWait
                         + ". Done: " + done
                         + ". Failed: " + failed
@@ -787,11 +786,14 @@
 
         private final boolean stopOnException; // If true, don't rethrow Exception
         
-        private PoolTest(ThreadGroup threadGroup, int connHoldTime) {
-            this(threadGroup, connHoldTime, false);
-        }
-            
+        private final boolean loopOnce; // If true, don't repeat loop
+
         public PoolTest(ThreadGroup threadGroup, int connHoldTime, boolean isStopOnException) {
+            this(threadGroup, connHoldTime, isStopOnException, false);
+        }
+
+        private PoolTest(ThreadGroup threadGroup, int connHoldTime, boolean isStopOnException, boolean once) {
+            this.loopOnce = once;
             this.connHoldTime = connHoldTime;
             stopOnException = isStopOnException;
             isRun = true; // Must be done here so main thread is guaranteed to be able to set it false
@@ -831,6 +833,9 @@
                     state = "Closing Connection";
                     conn.close();
                     state = "Closed";
+                    if (loopOnce){
+                        break; // Or could set isRun=false
+                    }
                 }
                 state = DONE;
             } catch (Throwable t) {