use of cn.taketoday.framework.web.server.PortInUseException in project today-infrastructure by TAKETODAY.
the class UndertowServletWebServerFactoryTests method handleExceptionCausedByBlockedPortOnPrimaryConnector.
@Override
protected void handleExceptionCausedByBlockedPortOnPrimaryConnector(RuntimeException ex, int blockedPort) {
assertThat(ex).isInstanceOf(PortInUseException.class);
assertThat(((PortInUseException) ex).getPort()).isEqualTo(blockedPort);
Undertow undertow = (Undertow) ReflectionTestUtils.getField(this.webServer, "undertow");
Assertions.assertThat(undertow.getWorker()).isNull();
}
use of cn.taketoday.framework.web.server.PortInUseException in project today-framework by TAKETODAY.
the class UndertowServletWebServerFactoryTests method handleExceptionCausedByBlockedPortOnPrimaryConnector.
@Override
protected void handleExceptionCausedByBlockedPortOnPrimaryConnector(RuntimeException ex, int blockedPort) {
assertThat(ex).isInstanceOf(PortInUseException.class);
assertThat(((PortInUseException) ex).getPort()).isEqualTo(blockedPort);
Undertow undertow = (Undertow) ReflectionTestUtils.getField(this.webServer, "undertow");
Assertions.assertThat(undertow.getWorker()).isNull();
}
use of cn.taketoday.framework.web.server.PortInUseException in project today-framework by TAKETODAY.
the class NettyWebServer method start.
@Override
public void start() throws WebServerException {
DisposableServer disposableServer = this.disposableServer;
if (disposableServer == null) {
try {
disposableServer = startHttpServer();
this.disposableServer = disposableServer;
} catch (Exception ex) {
PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> {
if (bindException.localPort() > 0 && !isPermissionDenied(bindException.getCause())) {
throw new PortInUseException(bindException.localPort(), ex);
}
});
throw new WebServerException("Unable to start Netty", ex);
}
logger.info("Netty started{}", getStartedOnMessage(disposableServer));
startDaemonAwaitThread(disposableServer);
}
}
Aggregations