Skip to content

Commit

Permalink
Merge pull request #18175 from gaohanghang
Browse files Browse the repository at this point in the history
* pr/18175:
  Simplify code

Closes gh-18175
  • Loading branch information
snicoll committed Sep 9, 2019
2 parents 41111ac + 74d2fe4 commit cd8fab8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ enum Unit {
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected JettyResourceFactory getResourceFactory() {
}

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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public JettyServletWebServerFactory(String contextPath, int port) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected void configureContext(Context context) {
}

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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void addJasperInitializer(TomcatEmbeddedContext context) {

// 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static class Deserializer extends KeyDeserializer {
@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()));
}

}
Expand Down

0 comments on commit cd8fab8

Please sign in to comment.