The javadoc for WebServer.getPort() states that it returns "the port (or -1 if none)". The implementations appear to return 0.

Comment From: philwebb

Flagging to see if we should change the code or the javadoc.

Comment From: mbhave

When setting the port 0 is used for selecting a random port and -1 to disable. That makes me think the javadoc is correct.

Comment From: wilkinsona

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).

Comment From: mbhave

Good point @wilkinsona.

Comment From: philwebb

We're going to change the implementation not the javadoc

Comment From: spartusch

Hi everyone, I've created a PR for this issue https://github.com/spring-projects/spring-boot/pull/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.

Comment From: philwebb

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.