Simplify JettyWebServer.getLocalPort

Closes gh-24656
pull/25690/head
Stephane Nicoll 4 years ago
parent 4fcbfd3e84
commit b860d3892d

@ -39,7 +39,6 @@ import org.springframework.boot.web.server.PortInUseException;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
@ -261,21 +260,9 @@ public class JettyWebServer implements WebServer {
}
private Integer getLocalPort(Connector connector) {
try {
if (connector instanceof NetworkConnector) {
return ((NetworkConnector) connector).getLocalPort();
}
}
catch (Exception ex) {
}
try {
// Jetty 9 internals are different, but the method name is the same
return (Integer) ReflectionUtils
.invokeMethod(ReflectionUtils.findMethod(connector.getClass(), "getLocalPort"), connector);
}
catch (Exception ex) {
logger.info("could not determine port (" + ex.getMessage() + ")");
}
return 0;
}

Loading…
Cancel
Save