You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/09/06 11:08:00 UTC

svn commit: r1165571 - /httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java

Author: olegk
Date: Tue Sep  6 09:08:00 2011
New Revision: 1165571

URL: http://svn.apache.org/viewvc?rev=1165571&view=rev
Log:
Fixed intermittent test case failures caused by thread race conditions

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java?rev=1165571&r1=1165570&r2=1165571&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java Tue Sep  6 09:08:00 2011
@@ -428,14 +428,16 @@ public class TestConnPool {
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         GetPoolEntryThread t1 = new GetPoolEntryThread(future1);
         t1.start();
-        Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
-        GetPoolEntryThread t2 = new GetPoolEntryThread(future2);
-        t2.start();
 
         t1.join(GRACE_PERIOD);
         Assert.assertTrue(future1.isDone());
         LocalPoolEntry entry1 = t1.getEntry();
         Assert.assertNotNull(entry1);
+
+        Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
+        GetPoolEntryThread t2 = new GetPoolEntryThread(future2);
+        t2.start();
+
         t2.join(GRACE_PERIOD);
         Assert.assertTrue(future2.isDone());
         LocalPoolEntry entry2 = t2.getEntry();
@@ -470,6 +472,7 @@ public class TestConnPool {
         totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());
         Assert.assertEquals(1, totals.getLeased());
+
     }
 
     @Test
@@ -559,14 +562,16 @@ public class TestConnPool {
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         GetPoolEntryThread t1 = new GetPoolEntryThread(future1);
         t1.start();
-        Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
-        GetPoolEntryThread t2 = new GetPoolEntryThread(future2, 50, TimeUnit.MICROSECONDS);
-        t2.start();
 
         t1.join(GRACE_PERIOD);
         Assert.assertTrue(future1.isDone());
         LocalPoolEntry entry1 = t1.getEntry();
         Assert.assertNotNull(entry1);
+
+        Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
+        GetPoolEntryThread t2 = new GetPoolEntryThread(future2, 50, TimeUnit.MICROSECONDS);
+        t2.start();
+
         t2.join(GRACE_PERIOD);
         Assert.assertTrue(t2.getException() instanceof TimeoutException);
         Assert.assertFalse(future2.isDone());