diff --git a/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java b/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java index 603f22139..5947b7ddd 100644 --- a/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java +++ b/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.BufferedSink; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -256,6 +257,31 @@ public final class WholeOperationTimeoutTest { } } + @Ignore( + "timeout.exit() is called when the first connection is released but timeout.enter() is not called again") + @Test + public void timeoutFollowingRedirectOnNewConnection() throws Exception { + MockWebServer otherServer = new MockWebServer(); + + server.enqueue( + new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_MOVED_TEMP) + .setHeader("Location", otherServer.url("/"))); + + otherServer.enqueue(new MockResponse().setHeadersDelay(500, TimeUnit.MILLISECONDS)); + + Request request = new Request.Builder().url(server.url("/")).build(); + + Call call = client.newCall(request); + call.timeout().timeout(250, TimeUnit.MILLISECONDS); + try { + Response response = call.execute(); + fail(); + } catch (IOException e) { + assertTrue(call.isCanceled()); + } + } + @Test public void noTimeout() throws Exception { server.enqueue(new MockResponse() .setHeadersDelay(250, TimeUnit.MILLISECONDS)