Skip to content

Commit

Permalink
Fix a race condition in the HttpClientModule tests. This seems to h…
Browse files Browse the repository at this point in the history
…appen when an exception is raised over the SSL socket: the socket is then closed but the `mockWebServer` still tries to access it when `shutdown()` is called.

PiperOrigin-RevId: 587722530
Change-Id: I37ba7f9013e68f751e47a8520f23c2bddb0ebb04
  • Loading branch information
tooryx authored and copybara-github committed Dec 4, 2023
1 parent 65e84d5 commit 52bd09e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public void setTrustAllCertificates_whenFalseAndCertIsInvalid_throws()
SSLHandshakeException.class,
() -> httpClient.send(get(mockWebServer.url("/")).withEmptyHeaders().build()));

mockWebServer.shutdown();
// Note: b/314642696 - After this point, the socket in mockWebServer was closed when the
// exception was raised. So working with the mockWebServer would be
// hazardous.
}

@Test
Expand All @@ -137,7 +139,9 @@ public void setTrustAllCertificates_whenBothCliAndConfigValuesAreSet_cliValueTak
SSLHandshakeException.class,
() -> httpClient.send(get(mockWebServer.url("/")).withEmptyHeaders().build()));

mockWebServer.shutdown();
// Note: b/314642696 - After this point, the socket in mockWebServer was closed when the
// exception was raised. So working with the mockWebServer would be
// hazardous.
}

@Test
Expand Down

0 comments on commit 52bd09e

Please sign in to comment.