Commit d1958154 authored by Phillip Webb's avatar Phillip Webb

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
parent 4822516f
...@@ -101,7 +101,7 @@ public class NettyWebServer implements WebServer { ...@@ -101,7 +101,7 @@ public class NettyWebServer implements WebServer {
} }
catch (Exception ex) { catch (Exception ex) {
PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> { PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> {
if (!isPermissionDenied(bindException.getCause())) { if (bindException.localPort() > 0 && !isPermissionDenied(bindException.getCause())) {
throw new PortInUseException(bindException.localPort(), ex); throw new PortInUseException(bindException.localPort(), ex);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment