Browse Source

Polish

pull/46766/head
Stéphane Nicoll 1 month ago
parent
commit
2e4566bd3d
  1. 10
      module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/HttpClientSettings.java
  2. 12
      module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/autoconfigure/HttpClientAutoConfiguration.java
  3. 2
      module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/autoconfigure/HttpClientSettingsPropertyMapper.java

10
module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/HttpClientSettings.java

@ -23,7 +23,7 @@ import org.jspecify.annotations.Nullable;
import org.springframework.boot.ssl.SslBundle; import org.springframework.boot.ssl.SslBundle;
/** /**
* Settings that can be applied when creating a imperative or reactive HTTP client. * Settings that can be applied when creating an imperative or reactive HTTP client.
* *
* @param redirects the follow redirect strategy to use or null to redirect whenever the * @param redirects the follow redirect strategy to use or null to redirect whenever the
* underlying library allows it * underlying library allows it
@ -38,14 +38,6 @@ public record HttpClientSettings(@Nullable HttpRedirects redirects, @Nullable Du
private static final HttpClientSettings defaults = new HttpClientSettings(null, null, null, null); private static final HttpClientSettings defaults = new HttpClientSettings(null, null, null, null);
public HttpClientSettings(@Nullable HttpRedirects redirects, @Nullable Duration connectTimeout,
@Nullable Duration readTimeout, @Nullable SslBundle sslBundle) {
this.redirects = redirects;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
this.sslBundle = sslBundle;
}
/** /**
* Return a new {@link HttpClientSettings} instance with an updated connect timeout * Return a new {@link HttpClientSettings} instance with an updated connect timeout
* setting. * setting.

12
module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/autoconfigure/HttpClientAutoConfiguration.java

@ -36,16 +36,12 @@ import org.springframework.context.annotation.Bean;
@EnableConfigurationProperties(HttpClientsProperties.class) @EnableConfigurationProperties(HttpClientsProperties.class)
public final class HttpClientAutoConfiguration { public final class HttpClientAutoConfiguration {
private final HttpClientSettingsPropertyMapper propertyMapper;
HttpClientAutoConfiguration(ObjectProvider<SslBundles> sslBundles) {
this.propertyMapper = new HttpClientSettingsPropertyMapper(sslBundles.getIfAvailable(), null);
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
HttpClientSettings httpClientSettings(HttpClientsProperties properties) { HttpClientSettings httpClientSettings(ObjectProvider<SslBundles> sslBundles, HttpClientsProperties properties) {
return this.propertyMapper.map(properties); HttpClientSettingsPropertyMapper propertyMapper = new HttpClientSettingsPropertyMapper(
sslBundles.getIfAvailable(), null);
return propertyMapper.map(properties);
} }
} }

2
module/spring-boot-http-client/src/main/java/org/springframework/boot/http/client/autoconfigure/HttpClientSettingsPropertyMapper.java

@ -57,7 +57,7 @@ public class HttpClientSettingsPropertyMapper {
return settings.orElse(this.settings); return settings.orElse(this.settings);
} }
private @Nullable SslBundle getSslBundle(String name) { private SslBundle getSslBundle(String name) {
Assert.state(this.sslBundles != null, "No 'sslBundles' available"); Assert.state(this.sslBundles != null, "No 'sslBundles' available");
return this.sslBundles.getBundle(name); return this.sslBundles.getBundle(name);
} }

Loading…
Cancel
Save