aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java
index 3d48658..0b18783 100644
--- a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java
+++ b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java
@@ -1650,9 +1650,16 @@ public final class CallTest {
}
@Test public void cancelInFlightBeforeResponseReadThrowsIOE() throws Exception {
+ final CountDownLatch cancelSignal = new CountDownLatch(1);
+
server.setDispatcher(new Dispatcher() {
@Override public MockResponse dispatch(RecordedRequest request) {
client.cancel("request");
+ try {
+ cancelSignal.await(10L, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ // Do nothing
+ }
return new MockResponse().setBody("A");
}
});
@@ -1662,6 +1669,7 @@ public final class CallTest {
client.newCall(request).execute();
fail();
} catch (IOException expected) {
+ cancelSignal.countDown();
}
}