Skip to content

Commit a920011

Browse files
committed
Deprecate ClientHttpRequestFactories
Deprecate `ClientHttpRequestFactories` and refactor its internals to delegate to the new `ClientHttpRequestFactoryBuilder` interface. Closes gh-36266
1 parent 3a8b2e4 commit a920011

File tree

14 files changed

+51
-353
lines changed

14 files changed

+51
-353
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/rest-client.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ The following code shows a typical example:
125125

126126
include-code::MyService[]
127127

128-
If you need to apply other customization in addition to an SSL bundle, you can use the `ClientHttpRequestFactorySettings` class with `ClientHttpRequestFactories`:
128+
If you need to apply other customization in addition to an SSL bundle, you can use the `ClientHttpRequestFactorySettings` class with `ClientHttpRequestFactoryBuilder`:
129129

130130
include-code::settings/MyService[]
131131

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/io/restclient/restclient/ssl/settings/MyService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -18,9 +18,9 @@
1818

1919
import java.time.Duration;
2020

21+
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
22+
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
2123
import org.springframework.boot.ssl.SslBundles;
22-
import org.springframework.boot.web.client.ClientHttpRequestFactories;
23-
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
2424
import org.springframework.http.client.ClientHttpRequestFactory;
2525
import org.springframework.stereotype.Service;
2626
import org.springframework.web.client.RestClient;
@@ -31,10 +31,10 @@ public class MyService {
3131
private final RestClient restClient;
3232

3333
public MyService(RestClient.Builder restClientBuilder, SslBundles sslBundles) {
34-
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.DEFAULTS
35-
.withReadTimeout(Duration.ofMinutes(2))
36-
.withSslBundle(sslBundles.getBundle("mybundle"));
37-
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(settings);
34+
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings
35+
.ofSslBundle(sslBundles.getBundle("mybundle"))
36+
.withReadTimeout(Duration.ofMinutes(2));
37+
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactoryBuilder.detect().build(settings);
3838
this.restClient = restClientBuilder.baseUrl("https://example.org").requestFactory(requestFactory).build();
3939
}
4040

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/restclient/ssl/settings/MyService.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.boot.docs.io.restclient.restclient.ssl.settings
1818

19+
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
20+
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
1921
import org.springframework.boot.ssl.SslBundles
20-
import org.springframework.boot.web.client.ClientHttpRequestFactories
21-
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings
2222
import org.springframework.stereotype.Service
2323
import org.springframework.web.client.RestClient
2424
import java.time.Duration
@@ -29,10 +29,10 @@ class MyService(restClientBuilder: RestClient.Builder, sslBundles: SslBundles) {
2929
private val restClient: RestClient
3030

3131
init {
32-
val settings = ClientHttpRequestFactorySettings.DEFAULTS
32+
val settings = ClientHttpRequestFactorySettings.defaults()
3333
.withReadTimeout(Duration.ofMinutes(2))
3434
.withSslBundle(sslBundles.getBundle("mybundle"))
35-
val requestFactory = ClientHttpRequestFactories.get(settings)
35+
val requestFactory = ClientHttpRequestFactoryBuilder.detect().build(settings);
3636
restClient = restClientBuilder
3737
.baseUrl("https://example.org")
3838
.requestFactory(requestFactory).build()

0 commit comments

Comments
 (0)