From e973eaf2c3552c1bba431d0d3e4aef75e3ca8995 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 22 Jan 2018 09:47:02 +0000 Subject: [PATCH] Configure WebClient to use same address (IPv4 or IPv6) as server Closes gh-11712 --- .../server/AbstractReactiveWebServerFactoryTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java index 8043c46bbc..9369811233 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java @@ -18,6 +18,7 @@ package org.springframework.boot.web.reactive.server; import java.io.File; import java.io.FileInputStream; +import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.time.Duration; @@ -249,9 +250,11 @@ public abstract class AbstractReactiveWebServerFactoryTests { protected WebClient.Builder getWebClient( Consumer clientOptions) { + InetSocketAddress address = new InetSocketAddress(this.webServer.getPort()); + String baseUrl = "http://" + address.getHostString() + ":" + address.getPort(); return WebClient.builder() .clientConnector(new ReactorClientHttpConnector(clientOptions)) - .baseUrl("http://localhost:" + this.webServer.getPort()); + .baseUrl(baseUrl); } @Test