Change WebServer log messages to use port or ports, not port(s)

See gh-36103
This commit is contained in:
Ahmed Ashour
2023-06-28 12:39:54 +00:00
committed by Andy Wilkinson
parent 8c3f847bfe
commit 298bfd96c2
6 changed files with 41 additions and 19 deletions

View File

@@ -62,7 +62,7 @@ public class NettyRSocketServer implements RSocketServer {
@Override
public void start() throws RSocketServerException {
this.channel = block(this.starter, this.lifecycleTimeout);
logger.info("Netty RSocket started on port(s): " + address().getPort());
logger.info("Netty RSocket started on port " + address().getPort());
startDaemonAwaitThread(this.channel);
}

View File

@@ -168,7 +168,7 @@ public class JettyWebServer implements WebServer {
}
}
this.started = true;
logger.info("Jetty started on port(s) " + getActualPortsDescription() + " with context path '"
logger.info("Jetty started on " + getActualPortsDescription() + " with context path '"
+ getContextPath() + "'");
}
catch (WebServerException ex) {
@@ -184,10 +184,18 @@ public class JettyWebServer implements WebServer {
private String getActualPortsDescription() {
StringBuilder ports = new StringBuilder();
for (Connector connector : this.server.getConnectors()) {
if (ports.length() != 0) {
Connector[] connectors = this.server.getConnectors();
ports.append("port");
if (connectors.length != 1) {
ports.append("s");
}
ports.append(" ");
for (int i = 0; i < connectors.length; i++) {
if (i != 0) {
ports.append(", ");
}
Connector connector = connectors[i];
ports.append(getLocalPort(connector)).append(getProtocols(connector));
}
return ports.toString();

View File

@@ -105,7 +105,7 @@ public class TomcatWebServer implements WebServer {
}
private void initialize() throws WebServerException {
logger.info("Tomcat initialized with port(s): " + getPortsDescription(false));
logger.info("Tomcat initialized with " + getPortsDescription(false));
synchronized (this.monitor) {
try {
addInstanceIdToEngineName();
@@ -218,8 +218,8 @@ public class TomcatWebServer implements WebServer {
}
checkThatConnectorsHaveStarted();
this.started = true;
logger.info("Tomcat started on port(s): " + getPortsDescription(true) + " with context path '"
+ getContextPath() + "'");
logger.info("Tomcat started on " + getPortsDescription(true) + " with context path '" + getContextPath()
+ "'");
}
catch (ConnectorStartFailedException ex) {
stopSilently();
@@ -356,10 +356,14 @@ public class TomcatWebServer implements WebServer {
private String getPortsDescription(boolean localPort) {
StringBuilder ports = new StringBuilder();
for (Connector connector : this.tomcat.getService().findConnectors()) {
if (ports.length() != 0) {
ports.append(' ');
}
Connector[] connectors = this.tomcat.getService().findConnectors();
ports.append("port");
if (connectors.length != 1) {
ports.append("s");
}
for (Connector connector : connectors) {
ports.append(' ');
int port = localPort ? connector.getLocalPort() : connector.getPort();
ports.append(port).append(" (").append(connector.getScheme()).append(')');
}

View File

@@ -182,11 +182,21 @@ public class UndertowWebServer implements WebServer {
}
private String getPortsDescription() {
StringBuilder portsDescription = new StringBuilder();
List<UndertowWebServer.Port> ports = getActualPorts();
if (!ports.isEmpty()) {
return StringUtils.collectionToDelimitedString(ports, " ");
portsDescription.append("port");
if (ports.size() != 1) {
portsDescription.append("s");
}
return "unknown";
portsDescription.append(" ");
if (!ports.isEmpty()) {
portsDescription.append(StringUtils.collectionToDelimitedString(ports, " "));
}
else {
portsDescription.append("unknown");
}
return portsDescription.toString();
}
private List<Port> getActualPorts() {
@@ -315,7 +325,7 @@ public class UndertowWebServer implements WebServer {
}
protected String getStartLogMessage() {
return "Undertow started on port(s) " + getPortsDescription();
return "Undertow started on " + getPortsDescription();
}
/**