Skip to content

Commit 5620dfd

Browse files
committed
Set setReuseAddress on the test socket to try to reduce port conflicts (#3290)
(cherry picked from commit d8009cd)
1 parent 6edeffd commit 5620dfd

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • testutils/src/main/java/org/apache/cxf/testutil/common

testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ public static String getPortNumber(String fullName, String simpleName) {
198198
while (p == null) {
199199
int pn = portNum++;
200200
try (ServerSocket sock = new ServerSocket(pn)) {
201+
// Enable SO_REUSEADDR to allow faster port reuse after socket closure
202+
sock.setReuseAddress(true);
201203
//make sure the port can be opened. Something MIGHT be running on it.
202204
p = Integer.toString(pn);
203205
LOG.fine("Setting port for " + fullName + " to " + p);

0 commit comments

Comments
 (0)