|
16 | 16 |
|
17 | 17 | package org.springframework.core.testfixture.net;
|
18 | 18 |
|
19 |
| -import java.net.DatagramSocket; |
20 | 19 | import java.net.InetAddress;
|
21 | 20 | import java.net.ServerSocket;
|
22 | 21 | import java.util.Random;
|
|
26 | 25 | import org.springframework.util.Assert;
|
27 | 26 |
|
28 | 27 | /**
|
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. |
31 | 30 | *
|
32 |
| - * <p>Simple utility methods for working with network sockets — 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>. |
37 | 35 | *
|
38 | 36 | * <p>{@code SocketUtils} was introduced in Spring Framework 4.0, primarily to
|
39 | 37 | * assist in writing integration tests which start an external server on an
|
40 | 38 | * available random port. However, these utilities make no guarantee about the
|
41 | 39 | * 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 |
44 | 42 | * that it selects or is assigned by the operating system. To interact with that
|
45 | 43 | * server, you should query the server for the port it is currently using.
|
46 | 44 | *
|
|
0 commit comments