Commit 2bf1cdb0 authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

[Cronet] Deflake CronetHttpURLConnectionTest#testIOExceptionInterruptRethrown

Don't test system impl as it doesn't always respond to interrupt.
Attempt to reduce race in test.

Bug: 866911
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester
Change-Id: I74dc6c4ffdec4654cb0e0ab2912fb54a8564d717
Reviewed-on: https://chromium-review.googlesource.com/1152988Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578639}
parent 27548c03
...@@ -1427,13 +1427,8 @@ public class CronetHttpURLConnectionTest { ...@@ -1427,13 +1427,8 @@ public class CronetHttpURLConnectionTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"Cronet"}) @Feature({"Cronet"})
@CompareDefaultWithCronet @OnlyRunCronetHttpURLConnection // System impl flakily responds to interrupt.
public void testIOExceptionInterruptRethrown() throws Exception { public void testIOExceptionInterruptRethrown() throws Exception {
// Older system impls don't reliably respond to interrupt.
if (mTestRule.testingSystemHttpURLConnection()
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
ServerSocket hangingServer = new ServerSocket(0); ServerSocket hangingServer = new ServerSocket(0);
URL url = new URL("http://localhost:" + hangingServer.getLocalPort()); URL url = new URL("http://localhost:" + hangingServer.getLocalPort());
final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
...@@ -1460,6 +1455,7 @@ public class CronetHttpURLConnectionTest { ...@@ -1460,6 +1455,7 @@ public class CronetHttpURLConnectionTest {
t.start(); t.start();
Socket s = hangingServer.accept(); Socket s = hangingServer.accept();
hangingServer.close(); hangingServer.close();
Thread.sleep(100); // Give time for thread to get blocked, so interrupt is noticed.
// This will trigger an InterruptException in getHeaderField() and getResponseCode(). // This will trigger an InterruptException in getHeaderField() and getResponseCode().
// getHeaderField() should not re-throw it. getResponseCode() should re-throw it as an // getHeaderField() should not re-throw it. getResponseCode() should re-throw it as an
// InterruptedIOException. // InterruptedIOException.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment