Skip to content

Commit b2abc8f

Browse files
committed
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
1 parent 7f51984 commit b2abc8f

File tree

1 file changed

+1
-1
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty

1 file changed

+1
-1
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void start() throws WebServerException {
101101
}
102102
catch (Exception ex) {
103103
PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> {
104-
if (!isPermissionDenied(bindException.getCause())) {
104+
if (bindException.localPort() > 0 && !isPermissionDenied(bindException.getCause())) {
105105
throw new PortInUseException(bindException.localPort(), ex);
106106
}
107107
});

0 commit comments

Comments
 (0)