1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-08 23:42:08 +03:00

Fix crash on repeated MockWebServer shutdown

The problem was the awaitIdle() call was scheduling executor jobs after
the ExecutorService had been shut down. This fixes that and defends
against other races.
This commit is contained in:
Jesse Wilson
2019-12-30 23:27:40 -05:00
parent 975be25e22
commit edb5865b4c
6 changed files with 71 additions and 20 deletions

View File

@@ -87,7 +87,7 @@ class OkHttpClientTestRule : TestRule {
private fun ensureAllTaskQueuesIdle() {
for (queue in TaskRunner.INSTANCE.activeQueues()) {
assertThat(queue.awaitIdle(TimeUnit.MILLISECONDS.toNanos(1000L)))
assertThat(queue.idleLatch().await(1_000L, TimeUnit.MILLISECONDS))
.withFailMessage("Queue still active after 1000 ms")
.isTrue()
}