From c42023f20e6f06f9be55e70102818b3f2e9dbe84 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 15 Feb 2022 14:59:09 +0100 Subject: [PATCH] Stop using SocketUtils in WebClientIntegrationTests See gh-28052 --- .../function/client/WebClientIntegrationTests.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index 4fd096fa1c1..d48d17a8215 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -34,6 +34,7 @@ import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -1246,12 +1247,12 @@ class WebClientIntegrationTests { private Mono doMalformedChunkedResponseTest( ClientHttpConnector connector, Function> handler) { - @SuppressWarnings("deprecation") - int port = org.springframework.util.SocketUtils.findAvailableTcpPort(); + AtomicInteger port = new AtomicInteger(); Thread serverThread = new Thread(() -> { // No way to simulate a malformed chunked response through MockWebServer. - try (ServerSocket serverSocket = new ServerSocket(port)) { + try (ServerSocket serverSocket = new ServerSocket(0)) { + port.set(serverSocket.getLocalPort()); Socket socket = serverSocket.accept(); InputStream is = socket.getInputStream();