|
|
|
|
@ -16,11 +16,11 @@
@@ -16,11 +16,11 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.web.embedded.netty; |
|
|
|
|
|
|
|
|
|
import java.net.BindException; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
import reactor.netty.ChannelBindException; |
|
|
|
|
import reactor.netty.DisposableServer; |
|
|
|
|
import reactor.netty.http.HttpResources; |
|
|
|
|
import reactor.netty.http.server.HttpServer; |
|
|
|
|
@ -69,8 +69,9 @@ public class NettyWebServer implements WebServer {
@@ -69,8 +69,9 @@ public class NettyWebServer implements WebServer {
|
|
|
|
|
this.disposableServer = startHttpServer(); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { |
|
|
|
|
if (findBindException(ex) != null) { |
|
|
|
|
throw new PortInUseException(getPort()); |
|
|
|
|
ChannelBindException bindException = findBindException(ex); |
|
|
|
|
if (bindException != null) { |
|
|
|
|
throw new PortInUseException(bindException.localPort()); |
|
|
|
|
} |
|
|
|
|
throw new WebServerException("Unable to start Netty", ex); |
|
|
|
|
} |
|
|
|
|
@ -87,11 +88,11 @@ public class NettyWebServer implements WebServer {
@@ -87,11 +88,11 @@ public class NettyWebServer implements WebServer {
|
|
|
|
|
return this.httpServer.handle(this.handlerAdapter).bindNow(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private BindException findBindException(Exception ex) { |
|
|
|
|
private ChannelBindException findBindException(Exception ex) { |
|
|
|
|
Throwable candidate = ex; |
|
|
|
|
while (candidate != null) { |
|
|
|
|
if (candidate instanceof BindException) { |
|
|
|
|
return (BindException) candidate; |
|
|
|
|
if (candidate instanceof ChannelBindException) { |
|
|
|
|
return (ChannelBindException) candidate; |
|
|
|
|
} |
|
|
|
|
candidate = candidate.getCause(); |
|
|
|
|
} |
|
|
|
|
|