Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert SAM #6828

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
yschimke marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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