DATAES-766 - Adapt RestClients class to change in InetSocketAddress class in JDK14.

Original PR: #417
This commit is contained in:
Peter-Josef Meisch 2020-04-01 07:55:04 +02:00 committed by GitHub
parent 403d9d08e2
commit bce9da4343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.web.reactive.function.client.WebClient;
/**
@ -153,6 +154,7 @@ public interface ClientConfiguration {
* @return the path prefix.
* @since 4.0
*/
@Nullable
String getPathPrefix();
/**

View File

@ -47,14 +47,15 @@ class DefaultClientConfiguration implements ClientConfiguration {
private final @Nullable SSLContext sslContext;
private final Duration soTimeout;
private final Duration connectTimeout;
private final String pathPrefix;
private final @Nullable String pathPrefix;
private final @Nullable HostnameVerifier hostnameVerifier;
private final String proxy;
private final Function<WebClient, WebClient> webClientConfigurer;
private final @Nullable String proxy;
private final @Nullable Function<WebClient, WebClient> webClientConfigurer;
DefaultClientConfiguration(List<InetSocketAddress> hosts, HttpHeaders headers, boolean useSsl,
@Nullable SSLContext sslContext, Duration soTimeout, Duration connectTimeout, @Nullable String pathPrefix,
@Nullable HostnameVerifier hostnameVerifier, String proxy, Function<WebClient, WebClient> webClientConfigurer) {
@Nullable HostnameVerifier hostnameVerifier, @Nullable String proxy,
@Nullable Function<WebClient, WebClient> webClientConfigurer) {
this.hosts = Collections.unmodifiableList(new ArrayList<>(hosts));
this.headers = new HttpHeaders(headers);
@ -103,6 +104,7 @@ class DefaultClientConfiguration implements ClientConfiguration {
return this.soTimeout;
}
@Nullable
@Override
public String getPathPrefix() {
return this.pathPrefix;

View File

@ -55,6 +55,7 @@ import org.springframework.util.Assert;
* @author Mark Paluch
* @author Huw Ayling-Miller
* @author Henrique Amaral
* @author Peter-Josef Meisch
* @since 3.2
*/
public final class RestClients {
@ -134,7 +135,7 @@ public final class RestClients {
}
private static List<String> formattedHosts(List<InetSocketAddress> hosts, boolean useSsl) {
return hosts.stream().map(it -> (useSsl ? "https" : "http") + "://" + it).collect(Collectors.toList());
return hosts.stream().map(it -> (useSsl ? "https" : "http") + "://" + it.getHostString() + ":" + it.getPort()).collect(Collectors.toList());
}
/**