-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using SocketUtils.findAvailableTcpPort() wherever possible #9382
Comments
@wilkinsona we are running into this while using |
The opening comment of this issue describes our best guess at why it is unreliable.
Not from Spring Boot's perspective as |
Please note that |
What can I do if I'm using org.springframework.util.SocketUtils.findAvailableTcpPort() |
@ahoehma this is explained in spring-projects/spring-framework#28052 |
If you have been using |
For those arriving here today, this is what you're looking for: spring-projects/spring-framework#29132 |
SocketUtils.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 thatfindAvailableTcpPort
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.The text was updated successfully, but these errors were encountered: