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
WebServer.getPort() returns 0 instead of -1 for closed connections #24540
Comments
Flagging to see if we should change the code or the javadoc. |
When setting the port |
The implementations could be correct too as I think we need to distinguish between being disabled (-1) and not knowing what the port is because the connector's stopped and it's configured to use an ephemeral port (0). |
Good point @wilkinsona. |
We're going to change the implementation not the javadoc |
The interface org.springframework.boot.web.server.WebServer defines that getPort() returns -1 if the server isn't listening on a port. This commit changes the implementations of the interface accordingly. See spring-projectsgh-24540
Hi everyone, I've created a PR for this issue #24606. I hope that's ok. It's my first contribution so I'm not familiar with the processes. In general the PR changes the implementations to return -1 instead of 0. |
Thanks @spartusch, I'll close this issue in favor of PR #24606 and we can continue any discussion there when we get a chance to review it. |
The javadoc for
WebServer.getPort()
states that it returns "the port (or -1 if none)". The implementations appear to return0
.The text was updated successfully, but these errors were encountered: