From f91d054a760ad78aeb9dc7e83435a2a954cb63eb Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Tue, 7 Jul 2026 14:54:42 +0100 Subject: [PATCH] Set setReuseAddress on the test socket to try to reduce port conflicts --- .../src/main/java/org/apache/cxf/testutil/common/TestUtil.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java b/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java index fad15c17f5f..859d1208933 100644 --- a/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java +++ b/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java @@ -198,6 +198,8 @@ public static String getPortNumber(String fullName, String simpleName) { while (p == null) { int pn = portNum++; try (ServerSocket sock = new ServerSocket(pn)) { + // Enable SO_REUSEADDR to allow faster port reuse after socket closure + sock.setReuseAddress(true); //make sure the port can be opened. Something MIGHT be running on it. p = Integer.toString(pn); LOG.fine("Setting port for " + fullName + " to " + p);