Skip to content

Commit

Permalink
Fix broken Android test on API 34
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed Jan 13, 2024
1 parent 3cc0f49 commit 0727fae
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions okhttp-android/src/main/kotlin/okhttp3/android/AndroidAsyncDns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,40 @@ class AndroidAsyncDns(
hostname: String,
callback: AsyncDns.Callback,
) {
resolver.query(
network,
hostname,
dnsClass.type,
DnsResolver.FLAG_EMPTY,
executor,
null,
object : DnsResolver.Callback<List<InetAddress>> {
override fun onAnswer(
addresses: List<InetAddress>,
rCode: Int,
) {
callback.onResponse(hostname, addresses)
}
try {
resolver.query(
network,
hostname,
dnsClass.type,
DnsResolver.FLAG_EMPTY,
executor,
null,
object : DnsResolver.Callback<List<InetAddress>> {
override fun onAnswer(
addresses: List<InetAddress>,
rCode: Int,
) {
callback.onResponse(hostname, addresses)
}

override fun onError(e: DnsResolver.DnsException) {
callback.onFailure(
hostname,
UnknownHostException(e.message).apply {
initCause(e)
},
)
}
},
)
override fun onError(e: DnsResolver.DnsException) {
callback.onFailure(
hostname,
UnknownHostException(e.message).apply {
initCause(e)
},
)
}
},
)
} catch (e: Exception) {
callback.onFailure(
hostname,
UnknownHostException(e.message).apply {
initCause(e)
},
)
}
}

companion object {
Expand Down

0 comments on commit 0727fae

Please sign in to comment.