Skip to content

Commit e6b5322

Browse files
fcappiphilwebb
authored andcommitted
Apply SslConfigurer in addition to configured mappers
Update `ReactorClientHttpConnectorFactory` to that SSL configuration is applied in addition to any configured mappers. Prior to this commit, SSL configuration would prevent configured mappers from being applied. See gh-35914
1 parent b770ffc commit e6b5322

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ReactorClientHttpConnectorFactory.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class ReactorClientHttpConnectorFactory implements ClientHttpConnectorFactory<Re
5555

5656
@Override
5757
public ReactorClientHttpConnector createClientHttpConnector(SslBundle sslBundle) {
58-
ReactorNettyHttpClientMapper mapper = this.mappers.get()
59-
.reduce((before, after) -> (client) -> after.configure(before.configure(client)))
60-
.orElse((client) -> client);
61-
if (sslBundle != null) {
62-
mapper = new SslConfigurer(sslBundle)::configure;
63-
}
64-
return new ReactorClientHttpConnector(this.reactorResourceFactory, mapper::configure);
58+
final ReactorNettyHttpClientMapper mapper =
59+
Stream.concat(
60+
this.mappers.get(),
61+
Stream.ofNullable(sslBundle != null ? (ReactorNettyHttpClientMapper) new SslConfigurer(sslBundle)::configure : null))
62+
.reduce((before, after) -> (client) -> after.configure(before.configure(client)))
63+
.orElse((client) -> client);
6564

65+
return new ReactorClientHttpConnector(this.reactorResourceFactory, mapper::configure);
6666
}
6767

6868
/**

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorFactoryConfigurationTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
import org.junit.jupiter.api.Test;
2525

2626
import org.springframework.boot.autoconfigure.AutoConfigurations;
27+
import org.springframework.boot.ssl.SslBundle;
28+
import org.springframework.boot.ssl.SslBundleKey;
29+
import org.springframework.boot.ssl.jks.JksSslStoreBundle;
30+
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
2731
import org.springframework.boot.test.context.FilteredClassLoader;
2832
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
2933
import org.springframework.context.annotation.Bean;
@@ -80,11 +84,14 @@ private JettyClientHttpConnectorFactory getJettyClientHttpConnectorFactory(
8084

8185
@Test
8286
void shouldApplyHttpClientMapper() {
87+
JksSslStoreDetails storeDetails = JksSslStoreDetails.forLocation("classpath:test.jks");
88+
JksSslStoreBundle stores = new JksSslStoreBundle(storeDetails, storeDetails);
89+
SslBundle sslBundle = SslBundle.of(stores, SslBundleKey.of("password"));
8390
new ReactiveWebApplicationContextRunner()
8491
.withConfiguration(AutoConfigurations.of(ClientHttpConnectorFactoryConfiguration.ReactorNetty.class))
8592
.withUserConfiguration(CustomHttpClientMapper.class)
8693
.run((context) -> {
87-
context.getBean(ReactorClientHttpConnectorFactory.class).createClientHttpConnector();
94+
context.getBean(ReactorClientHttpConnectorFactory.class).createClientHttpConnector(sslBundle);
8895
assertThat(CustomHttpClientMapper.called).isTrue();
8996
});
9097
}

0 commit comments

Comments
 (0)