Skip to content

Commit 542b642

Browse files
committed
Revise documentation for TestSocketUtils
1 parent 2ab871f commit 542b642

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spring-core/src/testFixtures/java/org/springframework/core/testfixture/net/TestSocketUtils.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.core.testfixture.net;
1818

19-
import java.net.DatagramSocket;
2019
import java.net.InetAddress;
2120
import java.net.ServerSocket;
2221
import java.util.Random;
@@ -26,21 +25,20 @@
2625
import org.springframework.util.Assert;
2726

2827
/**
29-
* Removed from spring-core and introduced as an internal test utility in
30-
* spring-context in Spring Framework 6.0.
28+
* Simple utility methods for finding available ports on {@code localhost} for
29+
* use in integration testing scenarios.
3130
*
32-
* <p>Simple utility methods for working with network sockets &mdash; for example,
33-
* for finding available ports on {@code localhost}.
34-
*
35-
* <p>Within this class, a TCP port refers to a port for a {@link ServerSocket};
36-
* whereas, a UDP port refers to a port for a {@link DatagramSocket}.
31+
* <p>{@code SocketUtils} was removed from the public API in {@code spring-core}
32+
* in Spring Framework 6.0 and reintroduced as {@code TestSocketUtils}, which is
33+
* made available to all tests in Spring Framework's test suite as a Gradle
34+
* <em>test fixture</em>.
3735
*
3836
* <p>{@code SocketUtils} was introduced in Spring Framework 4.0, primarily to
3937
* assist in writing integration tests which start an external server on an
4038
* available random port. However, these utilities make no guarantee about the
4139
* subsequent availability of a given port and are therefore unreliable. Instead
42-
* of using {@code SocketUtils} to find an available local port for a server, it
43-
* is recommended that you rely on a server's ability to start on a random port
40+
* of using {@code TestSocketUtils} to find an available local port for a server,
41+
* it is recommended that you rely on a server's ability to start on a random port
4442
* that it selects or is assigned by the operating system. To interact with that
4543
* server, you should query the server for the port it is currently using.
4644
*

0 commit comments

Comments
 (0)