Skip to content

Commit b6bcd36

Browse files
committed
All defaultRequestConfigCustomizer customizers should be invoked rather than only the last one
1 parent 48bc3b6 commit b6bcd36

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/http/client/HttpComponentsClientHttpRequestFactoryBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ public HttpComponentsClientHttpRequestFactoryBuilder withDefaultRequestConfigCus
182182
Consumer<RequestConfig.Builder> defaultRequestConfigCustomizer) {
183183
Assert.notNull(defaultRequestConfigCustomizer, "'defaultRequestConfigCustomizer' must not be null");
184184
return new HttpComponentsClientHttpRequestFactoryBuilder(getCustomizers(), this.httpClientCustomizer,
185-
this.connectionManagerCustomizer, this.socketConfigCustomizer, defaultRequestConfigCustomizer,
185+
this.connectionManagerCustomizer, this.socketConfigCustomizer,
186+
this.defaultRequestConfigCustomizer.andThen(defaultRequestConfigCustomizer),
186187
this.tlsSocketStrategyFactory);
187188
}
188189

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/http/client/HttpComponentsClientHttpRequestFactoryBuilderTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,24 @@ void withCustomizers() {
5555
TestCustomizer<HttpClientBuilder> httpClientCustomizer2 = new TestCustomizer<>();
5656
TestCustomizer<PoolingHttpClientConnectionManagerBuilder> connectionManagerCustomizer = new TestCustomizer<>();
5757
TestCustomizer<SocketConfig.Builder> socketConfigCustomizer = new TestCustomizer<>();
58+
TestCustomizer<SocketConfig.Builder> socketConfigCustomizer1 = new TestCustomizer<>();
5859
TestCustomizer<RequestConfig.Builder> defaultRequestConfigCustomizer = new TestCustomizer<>();
60+
TestCustomizer<RequestConfig.Builder> defaultRequestConfigCustomizer1 = new TestCustomizer<>();
5961
ClientHttpRequestFactoryBuilder.httpComponents()
6062
.withHttpClientCustomizer(httpClientCustomizer1)
6163
.withHttpClientCustomizer(httpClientCustomizer2)
6264
.withConnectionManagerCustomizer(connectionManagerCustomizer)
6365
.withSocketConfigCustomizer(socketConfigCustomizer)
66+
.withSocketConfigCustomizer(socketConfigCustomizer1)
6467
.withDefaultRequestConfigCustomizer(defaultRequestConfigCustomizer)
68+
.withDefaultRequestConfigCustomizer(defaultRequestConfigCustomizer1)
6569
.build();
6670
httpClientCustomizer1.assertCalled();
6771
httpClientCustomizer2.assertCalled();
6872
connectionManagerCustomizer.assertCalled();
6973
socketConfigCustomizer.assertCalled();
7074
defaultRequestConfigCustomizer.assertCalled();
75+
defaultRequestConfigCustomizer1.assertCalled();
7176
}
7277

7378
@Test

0 commit comments

Comments
 (0)