hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1464365 - /httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
Date Thu, 04 Apr 2013 08:56:04 GMT
Author: olegk
Date: Thu Apr  4 08:56:04 2013
New Revision: 1464365

URL: http://svn.apache.org/r1464365
Log:
Fixed synchronization bug

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java?rev=1464365&r1=1464364&r2=1464365&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
Thu Apr  4 08:56:04 2013
@@ -38,6 +38,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import junit.framework.Assert;
 
@@ -150,9 +151,9 @@ public class TestFutureRequestExecutionS
 
         latch.await(10, TimeUnit.SECONDS);
 
-        Assert.assertEquals(100, callback.completed);
-        Assert.assertEquals(0, callback.cancelled);
-        Assert.assertEquals(0, callback.failed);
+        Assert.assertEquals(100, callback.completed.get());
+        Assert.assertEquals(0, callback.cancelled.get());
+        Assert.assertEquals(0, callback.failed.get());
     }
 
 
@@ -160,9 +161,9 @@ public class TestFutureRequestExecutionS
 
         private final CountDownLatch latch;
 
-        int failed=0;
-        int cancelled=0;
-        int completed=0;
+        AtomicInteger failed = new AtomicInteger(0);
+        AtomicInteger cancelled = new AtomicInteger(0);
+        AtomicInteger completed = new AtomicInteger(0);
 
         CountingCallback(final CountDownLatch latch) {
             super();
@@ -171,17 +172,17 @@ public class TestFutureRequestExecutionS
 
         public void failed(final Exception ex) {
             latch.countDown();
-            failed++;
+            failed.incrementAndGet();
         }
 
         public void completed(final Boolean result) {
             latch.countDown();
-            completed++;
+            completed.incrementAndGet();
         }
 
         public void cancelled() {
             latch.countDown();
-            cancelled++;
+            cancelled.incrementAndGet();
         }
     }
 



Mime
View raw message