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:
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user