Merge branch '1.5.x' into 2.0.x

This commit is contained in:
Phillip Webb
2018-05-03 12:43:50 -07:00
138 changed files with 274 additions and 269 deletions

View File

@@ -85,8 +85,8 @@ public class RemoteDevToolsAutoConfiguration {
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper(
(this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
(this.serverProperties.getServlet().getContextPath() != null
? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath(),
handler);
}
@@ -127,8 +127,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
String url = (this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
String url = (this.serverProperties.getServlet().getContextPath() != null
? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath() + "/restart";
logger.warn("Listening for remote restart updates on " + url);
Handler handler = new HttpRestartServerHandler(server);

View File

@@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
File home = getHomeFolder();
File propertyFile = (home == null ? null : new File(home, FILE_NAME));
File propertyFile = (home != null ? new File(home, FILE_NAME) : null);
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
FileSystemResource resource = new FileSystemResource(propertyFile);
Properties properties;

View File

@@ -133,7 +133,7 @@ public class ClassPathChangeUploader
private void logUpload(ClassLoaderFiles classLoaderFiles) {
int size = classLoaderFiles.size();
logger.info(
"Uploaded " + size + " class " + (size == 1 ? "resource" : "resources"));
"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 ? null
: FileCopyUtils.copyToByteArray(changedFile.getFile()));
long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
: changedFile.getFile().lastModified());
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);
}

View File

@@ -55,7 +55,7 @@ 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,
Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null,
() -> "Contents must " + (kind == Kind.DELETED ? "" : "not ")
+ "be null");
this.kind = kind;

View File

@@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection {
throw new IllegalArgumentException("Malformed URL '" + url + "'");
}
this.requestFactory = requestFactory;
this.executor = (executor == null
? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor);
this.executor = (executor != null ? executor
: Executors.newCachedThreadPool(new TunnelThreadFactory()));
}
@Override

View File

@@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests {
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
assertThat(file.getContents())
.isEqualTo(content == null ? null : content.getBytes());
.isEqualTo(content != null ? content.getBytes() : null);
assertThat(file.getKind()).isEqualTo(kind);
}