Stop using SocketUtils.findAvailableTcpPort() wherever possible
See original GitHub issueSocketUtils.findAvailableTcpPort() is rather unreliable leading to intermittent test failures because a port is already in use. I’m not sure if this happens because the socket that findAvailableTcpPort opens to get a free port doesn’t actually release the port, or if something else just happens to grab the same port. The end result is the same either way.
In the interests of making the build more stable, I’d like to stop using SocketUtils.findAvailableTcpPort() wherever possible. In its place, we should pass in a port of 0 to whatever’s going to open a socket, and then use the port that the OS allocates. This will require some changes to some main code, TunnelClient for example, but I think it’s worth it to improve the stability of the build.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
Top Related StackOverflow Question
Please note that
SocketUtilshas been deprecated in Spring Framework 5.3.16:For those arriving here today, this is what you’re looking for: https://github.com/spring-projects/spring-framework/pull/29132