Skip to content

Commit efb6abc

Browse files
committed
Deprecate OkHttp3ClientHttpRequestFactory
Closes gh-30919
1 parent 3d57425 commit efb6abc

File tree

8 files changed

+11
-6
lines changed

8 files changed

+11
-6
lines changed

spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* @author Roy Clarkson
4141
* @since 4.3
4242
*/
43+
@Deprecated(since = "6.1", forRemoval = true)
4344
class OkHttp3ClientHttpRequest extends AbstractStreamingClientHttpRequest {
4445

4546
private final OkHttpClient client;
@@ -67,6 +68,7 @@ public URI getURI() {
6768
}
6869

6970
@Override
71+
@SuppressWarnings("removal")
7072
protected ClientHttpResponse executeInternal(HttpHeaders headers, @Nullable Body body) throws IOException {
7173

7274
RequestBody requestBody;

spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
* @author Arjen Poutsma
3737
* @author Roy Clarkson
3838
* @since 4.3
39+
* @deprecated since 6.1, in favor of other {@link ClientHttpRequestFactory}
40+
* implementations; scheduled for removal in 6.2
3941
*/
42+
@Deprecated(since = "6.1", forRemoval = true)
4043
public class OkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, DisposableBean {
4144

4245
private OkHttpClient client;
@@ -128,6 +131,7 @@ public void setConnectTimeout(Duration connectTimeout) {
128131

129132

130133
@Override
134+
@SuppressWarnings("removal")
131135
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) {
132136
return new OkHttp3ClientHttpRequest(this.client, uri, httpMethod);
133137
}

spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* @author Roy Clarkson
3636
* @since 4.3
3737
*/
38+
@Deprecated(since = "6.1", forRemoval = true)
3839
class OkHttp3ClientHttpResponse implements ClientHttpResponse {
3940

4041
private final Response response;

spring-web/src/main/java/org/springframework/web/client/DefaultRestClientBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
3333
import org.springframework.http.client.JdkClientHttpRequestFactory;
3434
import org.springframework.http.client.JettyClientHttpRequestFactory;
35-
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
3635
import org.springframework.http.client.SimpleClientHttpRequestFactory;
3736
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
3837
import org.springframework.http.converter.HttpMessageConverter;
@@ -363,9 +362,6 @@ private ClientHttpRequestFactory initRequestFactory() {
363362
else if (httpComponentsClientPresent) {
364363
return new HttpComponentsClientHttpRequestFactory();
365364
}
366-
else if (okHttpClientPresent) {
367-
return new OkHttp3ClientHttpRequestFactory();
368-
}
369365
else if (jettyClientPresent) {
370366
return new JettyClientHttpRequestFactory();
371367
}

spring-web/src/main/java/org/springframework/web/client/RestClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ Builder defaultStatusHandler(Predicate<HttpStatusCode> statusPredicate,
348348
* client library (e.g. SSL).
349349
* <p>If no request factory is specified, {@code RestClient} uses
350350
* {@linkplain org.springframework.http.client.HttpComponentsClientHttpRequestFactory Apache Http Client},
351-
* {@linkplain org.springframework.http.client.OkHttp3ClientHttpRequestFactory OkHttp 3}, or
352351
* {@linkplain org.springframework.http.client.JettyClientHttpRequestFactory Jetty Http Client}
353352
* if available on the classpath, and defaults to the
354353
* {@linkplain org.springframework.http.client.JdkClientHttpRequestFactory JDK HttpClient}

spring-web/src/test/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactoryTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
*/
2626
public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
2727

28+
@SuppressWarnings("removal")
2829
@Override
2930
protected ClientHttpRequestFactory createRequestFactory() {
3031
return new OkHttp3ClientHttpRequestFactory();

spring-web/src/test/java/org/springframework/web/client/RestClientIntegrationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class RestClientIntegrationTests {
7272
@interface ParameterizedRestClientTest {
7373
}
7474

75+
@SuppressWarnings("removal")
7576
static Stream<Named<ClientHttpRequestFactory>> clientHttpRequestFactories() {
7677
return Stream.of(
7778
named("JDK HttpURLConnection", new SimpleClientHttpRequestFactory()),

spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
9191
@interface ParameterizedRestTemplateTest {
9292
}
9393

94+
@SuppressWarnings("removal")
9495
static Stream<Named<ClientHttpRequestFactory>> clientHttpRequestFactories() {
9596
return Stream.of(
9697
named("JDK HttpURLConnection", new SimpleClientHttpRequestFactory()),

0 commit comments

Comments
 (0)