Commit b860d389 authored by Stephane Nicoll's avatar Stephane Nicoll

Simplify JettyWebServer.getLocalPort

Closes gh-24656
parent 4fcbfd3e
...@@ -39,7 +39,6 @@ import org.springframework.boot.web.server.PortInUseException; ...@@ -39,7 +39,6 @@ import org.springframework.boot.web.server.PortInUseException;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException; import org.springframework.boot.web.server.WebServerException;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
...@@ -261,20 +260,8 @@ public class JettyWebServer implements WebServer { ...@@ -261,20 +260,8 @@ public class JettyWebServer implements WebServer {
} }
private Integer getLocalPort(Connector connector) { private Integer getLocalPort(Connector connector) {
try { if (connector instanceof NetworkConnector) {
if (connector instanceof NetworkConnector) { return ((NetworkConnector) connector).getLocalPort();
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; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment