You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2026/07/08 09:12:48 UTC

(cxf) 02/02: Set setReuseAddress on the test socket to try to reduce port conflicts (#3290)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 5620dfd145557e42830dfcec0ca3116e6767c58a
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Wed Jul 8 09:51:53 2026 +0100

    Set setReuseAddress on the test socket to try to reduce port conflicts (#3290)
    
    (cherry picked from commit d8009cd959308d0448705d3d46621758fe4b37c1)
---
 testutils/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 final class TestUtil {
         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);