Only throw PortInUseException if port is set

Refine the `PortInUseException` logic in `NettyWebServer` to only throw
an exception if the port is set. The prevents a misleading exception
from being thrown when a domain socket is being used.

Closes gh-24529
pull/24549/head
Phillip Webb 4 years ago
parent 7f51984cbd
commit b2abc8ff3f

@ -101,7 +101,7 @@ public class NettyWebServer implements WebServer {
}
catch (Exception ex) {
PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> {
if (!isPermissionDenied(bindException.getCause())) {
if (bindException.localPort() > 0 && !isPermissionDenied(bindException.getCause())) {
throw new PortInUseException(bindException.localPort(), ex);
}
});

Loading…
Cancel
Save