From f47ca0f2686ce1028a73573c13a33ce4683f06a8 Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Wed, 4 Feb 2026 20:12:10 +0000 Subject: [PATCH] Avoid flakes --- okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt index cc731bbe8ccc..8c7691450de5 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt @@ -19,11 +19,13 @@ import assertk.assertThat import assertk.assertions.containsExactly import java.net.InetAddress import java.net.UnknownHostException +import java.util.Collections import okio.Buffer class FakeDns : Dns { - private val hostAddresses: MutableMap> = mutableMapOf() - private val requestedHosts: MutableList = mutableListOf() + private val hostAddresses: MutableMap> = + Collections.synchronizedMap(mutableMapOf()) + private val requestedHosts: MutableList = Collections.synchronizedList(mutableListOf()) private var nextAddress = 0xff000064L // 255.0.0.100 in IPv4; ::ff00:64 in IPv6. /** Sets the results for `hostname`. */