Fixed synchronization bug
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1464365 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1242243793
commit
69a7589ad5
|
@ -38,6 +38,7 @@ import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
@ -150,9 +151,9 @@ public class TestFutureRequestExecutionService {
|
||||||
|
|
||||||
latch.await(10, TimeUnit.SECONDS);
|
latch.await(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
Assert.assertEquals(100, callback.completed);
|
Assert.assertEquals(100, callback.completed.get());
|
||||||
Assert.assertEquals(0, callback.cancelled);
|
Assert.assertEquals(0, callback.cancelled.get());
|
||||||
Assert.assertEquals(0, callback.failed);
|
Assert.assertEquals(0, callback.failed.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,9 +161,9 @@ public class TestFutureRequestExecutionService {
|
||||||
|
|
||||||
private final CountDownLatch latch;
|
private final CountDownLatch latch;
|
||||||
|
|
||||||
int failed=0;
|
AtomicInteger failed = new AtomicInteger(0);
|
||||||
int cancelled=0;
|
AtomicInteger cancelled = new AtomicInteger(0);
|
||||||
int completed=0;
|
AtomicInteger completed = new AtomicInteger(0);
|
||||||
|
|
||||||
CountingCallback(final CountDownLatch latch) {
|
CountingCallback(final CountDownLatch latch) {
|
||||||
super();
|
super();
|
||||||
|
@ -171,17 +172,17 @@ public class TestFutureRequestExecutionService {
|
||||||
|
|
||||||
public void failed(final Exception ex) {
|
public void failed(final Exception ex) {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
failed++;
|
failed.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completed(final Boolean result) {
|
public void completed(final Boolean result) {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
completed++;
|
completed.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelled() {
|
public void cancelled() {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
cancelled++;
|
cancelled.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue