Skip to content

Commit

Permalink
Convert SAM (#6828)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Aug 28, 2021
1 parent d06a6e1 commit f54b300
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.io.IOException
import okhttp3.internal.http2.Http2Stream
import mockwebserver3.RecordedRequest

interface DuplexResponseBody {
fun interface DuplexResponseBody {
@Throws(IOException::class)
fun onRequest(request: RecordedRequest, http2Stream: Http2Stream)
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,9 @@ class OkHttpClientTestRule : BeforeEachCallback, AfterEachCallback {
* A network that resolves only one IP address per host. Use this when testing route selection
* fallbacks to prevent the host machine's various IP addresses from interfering.
*/
private val SINGLE_INET_ADDRESS_DNS = object : Dns {
override fun lookup(hostname: String): List<InetAddress> {
val addresses = Dns.SYSTEM.lookup(hostname)
return listOf(addresses[0])
}
private val SINGLE_INET_ADDRESS_DNS = Dns { hostname ->
val addresses = Dns.SYSTEM.lookup(hostname)
listOf(addresses[0])
}

private operator fun Throwable?.plus(throwable: Throwable): Throwable {
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/main/kotlin/okhttp3/Dns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import okhttp3.Dns.Companion.SYSTEM
*
* Implementations of this interface must be safe for concurrent use.
*/
interface Dns {
fun interface Dns {
/**
* Returns the IP addresses of `hostname`, in the order they will be attempted by OkHttp. If a
* connection to an address fails, OkHttp will retry the connection with the next address until
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package okhttp3.internal.tls

import java.security.cert.X509Certificate

interface TrustRootIndex {
fun interface TrustRootIndex {
/** Returns the trusted CA certificate that signed [cert]. */
fun findByIssuerAndSignature(cert: X509Certificate): X509Certificate?
}
4 changes: 1 addition & 3 deletions okhttp/src/test/java/okhttp3/KotlinSourceModernTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ class KotlinSourceModernTest {

@Test
fun dns() {
var dns: Dns = object : Dns {
override fun lookup(hostname: String): List<InetAddress> = TODO()
}
var dns: Dns = Dns { TODO() }

val system: Dns = Dns.SYSTEM
}
Expand Down
6 changes: 1 addition & 5 deletions okhttp/src/test/java/okhttp3/SocketChannelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ class SocketChannelTest(
}

val client = clientTestRule.newClientBuilder()
.dns(object : Dns {
override fun lookup(hostname: String): List<InetAddress> {
return listOf(InetAddress.getByName("localhost"))
}
})
.dns { listOf(InetAddress.getByName("localhost")) }
.callTimeout(4, SECONDS)
.writeTimeout(2, SECONDS)
.readTimeout(2, SECONDS)
Expand Down

0 comments on commit f54b300

Please sign in to comment.