Skip to content
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

SocketUtils does not properly detect available port on localhost [SPR-13321] #17906

Closed
spring-projects-issues opened this issue Aug 5, 2015 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: test Issues in the test module type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Gary Russell opened SPR-13321 and commented

Status Quo

SocketUtils attempts to find an unused socket.

This does not work (at least on OS X) if something is already bound to localhost but not to other network interfaces. Instead, the requested socket is successfully bound to other network interfaces.

Proposal

Since tests generally want to bind to localhost, SocketUtils should test the loopback interface to ensure that the port is actually available for localhost.

Further Resources

See pull request 1537 for a similar fix in Spring Integration.


Affects: 4.0 GA

Referenced from: pull request #853, and commits f151404

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Fixed in GitHub commit f151404:

Properly detect available port on localhost in SocketUtils

SocketUtils is used to find available ports on localhost; however, prior to this commit, SocketUtils incorrectly reported a port as available on localhost if another process was already bound to localhost on the given port but not to other network interfaces. In other words, SocketUtils determined that a given port was available for some interface though not necessarily for the loopback interface.

This commit addresses this issue by refactoring SocketUtils so that it tests the loopback interface to ensure that the port is actually available for localhost.

@spring-projects-issues spring-projects-issues added type: bug A general bug in: test Issues in the test module in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: test Issues in the test module type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants