Skip to content

Commit 385e70f

Browse files
authored
Fix a binary-incompatible API change in Interceptor.Chain (#9360)
* Fix a binary-incompatible API change in Interceptor.Chain * Explicitly depend on Okio I saw build flakes in CI on JDK8 without this file:///home/runner/work/okhttp/okhttp/mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/DeprecationBridge.kt:156:21 Symbol is declared in an unnamed module which is not read by current module.
1 parent c85c685 commit 385e70f

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

mockwebserver-deprecated/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies {
1212
"friendsApi"(projects.okhttp)
1313
api(projects.mockwebserver3)
1414
api(libs.junit)
15+
api(libs.square.okio)
1516

1617
testImplementation(projects.okhttpTestingSupport)
1718
testImplementation(projects.okhttpTls)

okhttp/api/android/okhttp.api

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,19 @@ public abstract interface class okhttp3/Interceptor$Chain {
772772
public abstract fun withAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
773773
public abstract fun withCache (Lokhttp3/Cache;)Lokhttp3/Interceptor$Chain;
774774
public abstract fun withCertificatePinner (Lokhttp3/CertificatePinner;)Lokhttp3/Interceptor$Chain;
775-
public abstract fun withConnectTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
775+
public abstract fun withConnectTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
776776
public abstract fun withConnectionPool (Lokhttp3/ConnectionPool;)Lokhttp3/Interceptor$Chain;
777777
public abstract fun withCookieJar (Lokhttp3/CookieJar;)Lokhttp3/Interceptor$Chain;
778778
public abstract fun withDns (Lokhttp3/Dns;)Lokhttp3/Interceptor$Chain;
779779
public abstract fun withHostnameVerifier (Ljavax/net/ssl/HostnameVerifier;)Lokhttp3/Interceptor$Chain;
780780
public abstract fun withProxy (Ljava/net/Proxy;)Lokhttp3/Interceptor$Chain;
781781
public abstract fun withProxyAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
782782
public abstract fun withProxySelector (Ljava/net/ProxySelector;)Lokhttp3/Interceptor$Chain;
783-
public abstract fun withReadTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
783+
public abstract fun withReadTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
784784
public abstract fun withRetryOnConnectionFailure (Z)Lokhttp3/Interceptor$Chain;
785785
public abstract fun withSocketFactory (Ljavax/net/SocketFactory;)Lokhttp3/Interceptor$Chain;
786786
public abstract fun withSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;Ljavax/net/ssl/X509TrustManager;)Lokhttp3/Interceptor$Chain;
787-
public abstract fun withWriteTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
787+
public abstract fun withWriteTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
788788
public abstract fun writeTimeoutMillis ()I
789789
}
790790

okhttp/api/jvm/okhttp.api

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,19 @@ public abstract interface class okhttp3/Interceptor$Chain {
772772
public abstract fun withAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
773773
public abstract fun withCache (Lokhttp3/Cache;)Lokhttp3/Interceptor$Chain;
774774
public abstract fun withCertificatePinner (Lokhttp3/CertificatePinner;)Lokhttp3/Interceptor$Chain;
775-
public abstract fun withConnectTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
775+
public abstract fun withConnectTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
776776
public abstract fun withConnectionPool (Lokhttp3/ConnectionPool;)Lokhttp3/Interceptor$Chain;
777777
public abstract fun withCookieJar (Lokhttp3/CookieJar;)Lokhttp3/Interceptor$Chain;
778778
public abstract fun withDns (Lokhttp3/Dns;)Lokhttp3/Interceptor$Chain;
779779
public abstract fun withHostnameVerifier (Ljavax/net/ssl/HostnameVerifier;)Lokhttp3/Interceptor$Chain;
780780
public abstract fun withProxy (Ljava/net/Proxy;)Lokhttp3/Interceptor$Chain;
781781
public abstract fun withProxyAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
782782
public abstract fun withProxySelector (Ljava/net/ProxySelector;)Lokhttp3/Interceptor$Chain;
783-
public abstract fun withReadTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
783+
public abstract fun withReadTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
784784
public abstract fun withRetryOnConnectionFailure (Z)Lokhttp3/Interceptor$Chain;
785785
public abstract fun withSocketFactory (Ljavax/net/SocketFactory;)Lokhttp3/Interceptor$Chain;
786786
public abstract fun withSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;Ljavax/net/ssl/X509TrustManager;)Lokhttp3/Interceptor$Chain;
787-
public abstract fun withWriteTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
787+
public abstract fun withWriteTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
788788
public abstract fun writeTimeoutMillis ()I
789789
}
790790

okhttp/src/commonJvmAndroid/kotlin/okhttp3/Interceptor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fun interface Interceptor {
107107
* Returns a new chain with the specified connect timeout.
108108
*/
109109
fun withConnectTimeout(
110-
timeout: Long,
110+
timeout: Int,
111111
unit: TimeUnit,
112112
): Chain
113113

@@ -120,7 +120,7 @@ fun interface Interceptor {
120120
* Returns a new chain with the specified read timeout.
121121
*/
122122
fun withReadTimeout(
123-
timeout: Long,
123+
timeout: Int,
124124
unit: TimeUnit,
125125
): Chain
126126

@@ -133,7 +133,7 @@ fun interface Interceptor {
133133
* Returns a new chain with the specified write timeout.
134134
*/
135135
fun withWriteTimeout(
136-
timeout: Long,
136+
timeout: Int,
137137
unit: TimeUnit,
138138
): Chain
139139

okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/http/RealInterceptorChain.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,34 @@ class RealInterceptorChain(
172172
override fun connectTimeoutMillis(): Int = connectTimeoutMillis
173173

174174
override fun withConnectTimeout(
175-
timeout: Long,
175+
timeout: Int,
176176
unit: TimeUnit,
177177
): Interceptor.Chain {
178178
check(exchange == null) { "Timeouts can't be adjusted in a network interceptor" }
179179

180-
return copy(connectTimeoutMillis = checkDuration("connectTimeout", timeout, unit))
180+
return copy(connectTimeoutMillis = checkDuration("connectTimeout", timeout.toLong(), unit))
181181
}
182182

183183
override fun readTimeoutMillis(): Int = readTimeoutMillis
184184

185185
override fun withReadTimeout(
186-
timeout: Long,
186+
timeout: Int,
187187
unit: TimeUnit,
188188
): Interceptor.Chain {
189189
check(exchange == null) { "Timeouts can't be adjusted in a network interceptor" }
190190

191-
return copy(readTimeoutMillis = checkDuration("readTimeout", timeout, unit))
191+
return copy(readTimeoutMillis = checkDuration("readTimeout", timeout.toLong(), unit))
192192
}
193193

194194
override fun writeTimeoutMillis(): Int = writeTimeoutMillis
195195

196196
override fun withWriteTimeout(
197-
timeout: Long,
197+
timeout: Int,
198198
unit: TimeUnit,
199199
): Interceptor.Chain {
200200
check(exchange == null) { "Timeouts can't be adjusted in a network interceptor" }
201201

202-
return copy(writeTimeoutMillis = checkDuration("writeTimeout", timeout, unit))
202+
return copy(writeTimeoutMillis = checkDuration("writeTimeout", timeout.toLong(), unit))
203203
}
204204

205205
override fun withDns(dns: Dns): Interceptor.Chain {

okhttp/src/jvmTest/kotlin/okhttp3/InterceptorOverridesTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ class InterceptorOverridesTest {
587587
override fun isDefaultValue(value: Cache?): Boolean = value == null
588588
}
589589

590-
object ProxyOverride : Override<java.net.Proxy?> {
590+
object ProxyOverride : Override<Proxy?> {
591591
override fun Interceptor.Chain.value(): java.net.Proxy? = proxy
592592

593593
override fun Interceptor.Chain.withOverride(value: java.net.Proxy?): Interceptor.Chain = withProxy(value)
@@ -786,7 +786,7 @@ class InterceptorOverridesTest {
786786
object ConnectTimeoutOverride : Override<Int> {
787787
override fun Interceptor.Chain.value(): Int = connectTimeoutMillis()
788788

789-
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withConnectTimeout(value.toLong(), TimeUnit.MILLISECONDS)
789+
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withConnectTimeout(value, TimeUnit.MILLISECONDS)
790790

791791
override fun OkHttpClient.Builder.withOverride(value: Int): OkHttpClient.Builder =
792792
connectTimeout(value.toLong(), TimeUnit.MILLISECONDS)
@@ -802,7 +802,7 @@ class InterceptorOverridesTest {
802802
object ReadTimeoutOverride : Override<Int> {
803803
override fun Interceptor.Chain.value(): Int = readTimeoutMillis()
804804

805-
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withReadTimeout(value.toLong(), TimeUnit.MILLISECONDS)
805+
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withReadTimeout(value, TimeUnit.MILLISECONDS)
806806

807807
override fun OkHttpClient.Builder.withOverride(value: Int): OkHttpClient.Builder = readTimeout(value.toLong(), TimeUnit.MILLISECONDS)
808808

@@ -817,7 +817,7 @@ class InterceptorOverridesTest {
817817
object WriteTimeoutOverride : Override<Int> {
818818
override fun Interceptor.Chain.value(): Int = writeTimeoutMillis()
819819

820-
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withWriteTimeout(value.toLong(), TimeUnit.MILLISECONDS)
820+
override fun Interceptor.Chain.withOverride(value: Int): Interceptor.Chain = withWriteTimeout(value, TimeUnit.MILLISECONDS)
821821

822822
override fun OkHttpClient.Builder.withOverride(value: Int): OkHttpClient.Builder = writeTimeout(value.toLong(), TimeUnit.MILLISECONDS)
823823

okhttp/src/jvmTest/kotlin/okhttp3/KotlinSourceModernTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,21 +1351,21 @@ class KotlinSourceModernTest {
13511351
override fun connectTimeoutMillis(): Int = TODO()
13521352

13531353
override fun withConnectTimeout(
1354-
timeout: Long,
1354+
timeout: Int,
13551355
unit: TimeUnit,
13561356
): Interceptor.Chain = TODO()
13571357

13581358
override fun readTimeoutMillis(): Int = TODO()
13591359

13601360
override fun withReadTimeout(
1361-
timeout: Long,
1361+
timeout: Int,
13621362
unit: TimeUnit,
13631363
): Interceptor.Chain = TODO()
13641364

13651365
override fun writeTimeoutMillis(): Int = TODO()
13661366

13671367
override fun withWriteTimeout(
1368-
timeout: Long,
1368+
timeout: Int,
13691369
unit: TimeUnit,
13701370
): Interceptor.Chain = TODO()
13711371

0 commit comments

Comments
 (0)