Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class ReactorClientHttpConnectorFactory implements ClientHttpConnectorFactory<Re

@Override
public ReactorClientHttpConnector createClientHttpConnector(SslBundle sslBundle) {
ReactorNettyHttpClientMapper mapper = this.mappers.get()
.reduce((before, after) -> (client) -> after.configure(before.configure(client)))
.orElse((client) -> client);
if (sslBundle != null) {
mapper = new SslConfigurer(sslBundle)::configure;
}
return new ReactorClientHttpConnector(this.reactorResourceFactory, mapper::configure);
final ReactorNettyHttpClientMapper mapper =
Stream.concat(
this.mappers.get(),
Stream.ofNullable(sslBundle != null ? (ReactorNettyHttpClientMapper) new SslConfigurer(sslBundle)::configure : null))
.reduce((before, after) -> (client) -> after.configure(before.configure(client)))
.orElse((client) -> client);

return new ReactorClientHttpConnector(this.reactorResourceFactory, mapper::configure);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import org.junit.jupiter.api.Test;

import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundleKey;
import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -80,11 +84,14 @@ private JettyClientHttpConnectorFactory getJettyClientHttpConnectorFactory(

@Test
void shouldApplyHttpClientMapper() {
JksSslStoreDetails storeDetails = JksSslStoreDetails.forLocation("classpath:test.jks");
JksSslStoreBundle stores = new JksSslStoreBundle(storeDetails, storeDetails);
SslBundle sslBundle = SslBundle.of(stores, SslBundleKey.of("password"));
new ReactiveWebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ClientHttpConnectorFactoryConfiguration.ReactorNetty.class))
.withUserConfiguration(CustomHttpClientMapper.class)
.run((context) -> {
context.getBean(ReactorClientHttpConnectorFactory.class).createClientHttpConnector();
context.getBean(ReactorClientHttpConnectorFactory.class).createClientHttpConnector(sslBundle);
assertThat(CustomHttpClientMapper.called).isTrue();
});
}
Expand Down