Merge pull request #18175 from gaohanghang

* pr/18175:
  Simplify code

Closes gh-18175
pull/18187/head
Stephane Nicoll 5 years ago
commit cd8fab8442

@ -221,7 +221,7 @@ public enum DurationStyle {
}
public Duration parse(String value) {
return Duration.of(Long.valueOf(value), this.chronoUnit);
return Duration.of(Long.parseLong(value), this.chronoUnit);
}
public String print(Duration value) {

@ -167,7 +167,7 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
}
protected Server createJettyServer(JettyHttpHandlerAdapter servlet) {
int port = (getPort() >= 0) ? getPort() : 0;
int port = Math.max(getPort(), 0);
InetSocketAddress address = new InetSocketAddress(getAddress(), port);
Server server = new Server(getThreadPool());
server.addConnector(createConnector(address, server));

@ -137,7 +137,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
int port = (getPort() >= 0) ? getPort() : 0;
int port = Math.max(getPort(), 0);
InetSocketAddress address = new InetSocketAddress(getAddress(), port);
Server server = createServer(address);
configureWebAppContext(context, initializers);

@ -176,7 +176,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
}
protected void customizeConnector(Connector connector) {
int port = (getPort() >= 0) ? getPort() : 0;
int port = Math.max(getPort(), 0);
connector.setPort(port);
if (StringUtils.hasText(this.getServerHeader())) {
connector.setAttribute("server", this.getServerHeader());

@ -299,7 +299,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
// Needs to be protected so it can be used by subclasses
protected void customizeConnector(Connector connector) {
int port = (getPort() >= 0) ? getPort() : 0;
int port = Math.max(getPort(), 0);
connector.setPort(port);
if (StringUtils.hasText(this.getServerHeader())) {
connector.setAttribute("server", this.getServerHeader());

@ -46,7 +46,7 @@ public class NameAndAgeJsonKeyComponent {
@Override
public NameAndAge deserializeKey(String key, DeserializationContext ctxt) throws IOException {
String[] keys = key.split("is");
return new NameAndAge(keys[0].trim(), Integer.valueOf(keys[1].trim()));
return new NameAndAge(keys[0].trim(), Integer.parseInt(keys[1].trim()));
}
}

Loading…
Cancel
Save