|
|
|
@ -88,20 +88,36 @@ public class UndertowWebServer implements WebServer {
|
|
|
|
|
.info("Undertow started on port(s) " + getPortsDescription());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
if (findBindException(ex) != null) {
|
|
|
|
|
List<UndertowWebServer.Port> failedPorts = getConfiguredPorts();
|
|
|
|
|
List<UndertowWebServer.Port> actualPorts = getActualPorts();
|
|
|
|
|
failedPorts.removeAll(actualPorts);
|
|
|
|
|
if (failedPorts.size() == 1) {
|
|
|
|
|
throw new PortInUseException(
|
|
|
|
|
failedPorts.iterator().next().getNumber());
|
|
|
|
|
try {
|
|
|
|
|
if (findBindException(ex) != null) {
|
|
|
|
|
List<UndertowWebServer.Port> failedPorts = getConfiguredPorts();
|
|
|
|
|
List<UndertowWebServer.Port> actualPorts = getActualPorts();
|
|
|
|
|
failedPorts.removeAll(actualPorts);
|
|
|
|
|
if (failedPorts.size() == 1) {
|
|
|
|
|
throw new PortInUseException(
|
|
|
|
|
failedPorts.iterator().next().getNumber());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new WebServerException("Unable to start embedded Undertow", ex);
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
stopSilently();
|
|
|
|
|
}
|
|
|
|
|
throw new WebServerException("Unable to start embedded Undertow", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void stopSilently() {
|
|
|
|
|
try {
|
|
|
|
|
if (this.undertow != null) {
|
|
|
|
|
this.undertow.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
// Ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BindException findBindException(Exception ex) {
|
|
|
|
|
Throwable candidate = ex;
|
|
|
|
|
while (candidate != null) {
|
|
|
|
|