Fix checkstyle ternary issues
Fix checkstyle issues with ternary expressions following the spring-javaformat upgrade. See gh-13932
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties.Servlet;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.devtools.remote.server.AccessManager;
|
||||
import org.springframework.boot.devtools.remote.server.Dispatcher;
|
||||
@@ -84,10 +85,11 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
|
||||
Handler handler = new HttpStatusHandler();
|
||||
Servlet servlet = this.serverProperties.getServlet();
|
||||
String servletContextPath = (servlet.getContextPath() != null)
|
||||
? servlet.getContextPath() : "";
|
||||
return new UrlHandlerMapper(
|
||||
(this.serverProperties.getServlet().getContextPath() != null
|
||||
? this.serverProperties.getServlet().getContextPath() : "")
|
||||
+ this.properties.getRemote().getContextPath(),
|
||||
servletContextPath + this.properties.getRemote().getContextPath(),
|
||||
handler);
|
||||
}
|
||||
|
||||
@@ -127,9 +129,11 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
|
||||
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
|
||||
String url = (this.serverProperties.getServlet().getContextPath() != null
|
||||
? this.serverProperties.getServlet().getContextPath() : "")
|
||||
+ this.properties.getRemote().getContextPath() + "/restart";
|
||||
Servlet servlet = this.serverProperties.getServlet();
|
||||
RemoteDevToolsProperties remote = this.properties.getRemote();
|
||||
String servletContextPath = (servlet.getContextPath() != null)
|
||||
? servlet.getContextPath() : "";
|
||||
String url = servletContextPath + remote.getContextPath() + "/restart";
|
||||
logger.warn("Listening for remote restart updates on " + url);
|
||||
Handler handler = new HttpRestartServerHandler(server);
|
||||
return new UrlHandlerMapper(url, handler);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment,
|
||||
SpringApplication application) {
|
||||
File home = getHomeFolder();
|
||||
File propertyFile = (home != null ? new File(home, FILE_NAME) : null);
|
||||
File propertyFile = (home != null) ? new File(home, FILE_NAME) : null;
|
||||
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
|
||||
FileSystemResource resource = new FileSystemResource(propertyFile);
|
||||
Properties properties;
|
||||
|
||||
@@ -132,8 +132,8 @@ public class ClassPathChangeUploader
|
||||
|
||||
private void logUpload(ClassLoaderFiles classLoaderFiles) {
|
||||
int size = classLoaderFiles.size();
|
||||
logger.info(
|
||||
"Uploaded " + size + " class " + (size != 1 ? "resources" : "resource"));
|
||||
logger.info("Uploaded " + size + " class "
|
||||
+ ((size != 1) ? "resources" : "resource"));
|
||||
}
|
||||
|
||||
private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException {
|
||||
@@ -160,10 +160,10 @@ public class ClassPathChangeUploader
|
||||
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
|
||||
throws IOException {
|
||||
ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
|
||||
byte[] bytes = (kind != Kind.DELETED
|
||||
? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null);
|
||||
long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified()
|
||||
: System.currentTimeMillis());
|
||||
byte[] bytes = (kind != Kind.DELETED)
|
||||
? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null;
|
||||
long lastModified = (kind != Kind.DELETED) ? changedFile.getFile().lastModified()
|
||||
: System.currentTimeMillis();
|
||||
return new ClassLoaderFile(kind, lastModified, bytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ public class ClassLoaderFile implements Serializable {
|
||||
*/
|
||||
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
|
||||
Assert.notNull(kind, "Kind must not be null");
|
||||
Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null,
|
||||
() -> "Contents must " + (kind != Kind.DELETED ? "not " : "")
|
||||
Assert.isTrue((kind != Kind.DELETED) ? contents != null : contents == null,
|
||||
() -> "Contents must " + ((kind != Kind.DELETED) ? "not " : "")
|
||||
+ "be null");
|
||||
this.kind = kind;
|
||||
this.lastModified = lastModified;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection {
|
||||
throw new IllegalArgumentException("Malformed URL '" + url + "'");
|
||||
}
|
||||
this.requestFactory = requestFactory;
|
||||
this.executor = (executor != null ? executor
|
||||
: Executors.newCachedThreadPool(new TunnelThreadFactory()));
|
||||
this.executor = (executor != null) ? executor
|
||||
: Executors.newCachedThreadPool(new TunnelThreadFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests {
|
||||
|
||||
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
|
||||
assertThat(file.getContents())
|
||||
.isEqualTo(content != null ? content.getBytes() : null);
|
||||
.isEqualTo((content != null) ? content.getBytes() : null);
|
||||
assertThat(file.getKind()).isEqualTo(kind);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory {
|
||||
|
||||
public ClientHttpResponse asHttpResponse(AtomicLong seq) {
|
||||
MockClientHttpResponse httpResponse = new MockClientHttpResponse(
|
||||
this.payload != null ? this.payload : NO_DATA, this.status);
|
||||
(this.payload != null) ? this.payload : NO_DATA, this.status);
|
||||
waitForDelay();
|
||||
if (this.payload != null) {
|
||||
httpResponse.getHeaders().setContentLength(this.payload.length);
|
||||
|
||||
Reference in New Issue
Block a user