1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-24 18:41:06 +03:00

Kotlin 1.4 dependency upgrade and language features (#5947)

This commit is contained in:
Yuri Schimke
2020-09-06 18:36:12 +03:00
committed by GitHub
parent 1589741a90
commit a76c40a935
37 changed files with 103 additions and 136 deletions

View File

@@ -92,14 +92,11 @@ class OkHttpClientTestRule : TestRule {
Logger.getLogger("javax.net.ssl").fn()
}
fun wrap(eventListener: EventListener) = object : EventListener.Factory {
override fun create(call: Call) = ClientRuleEventListener(eventListener) { addEvent(it) }
}
fun wrap(eventListener: EventListener) =
EventListener.Factory { ClientRuleEventListener(eventListener, ::addEvent) }
fun wrap(eventListenerFactory: EventListener.Factory) = object : EventListener.Factory {
override fun create(call: Call) =
ClientRuleEventListener(eventListenerFactory.create(call)) { addEvent(it) }
}
fun wrap(eventListenerFactory: EventListener.Factory) =
EventListener.Factory { call -> ClientRuleEventListener(eventListenerFactory.create(call), ::addEvent) }
/**
* Returns an OkHttpClient for tests to use as a starting point.
@@ -115,9 +112,8 @@ class OkHttpClientTestRule : TestRule {
if (client == null) {
client = OkHttpClient.Builder()
.dns(SINGLE_INET_ADDRESS_DNS) // Prevent unexpected fallback addresses.
.eventListenerFactory(object : EventListener.Factory {
override fun create(call: Call) = ClientRuleEventListener { addEvent(it) }
})
.eventListenerFactory(
EventListener.Factory { ClientRuleEventListener(logger = ::addEvent) })
.build()
testClient = client
}