From e2d87a89d0ab942df53e3029e1fe42411732a81f Mon Sep 17 00:00:00 2001 From: zhangt2333 Date: Sat, 15 Feb 2020 12:14:40 +0800 Subject: [PATCH 1/2] Polish See gh-20192 --- .../boot/actuate/endpoint/http/ApiVersion.java | 2 +- .../boot/cli/command/init/ProjectGenerator.java | 5 +---- .../boot/cli/compiler/DependencyCustomizer.java | 10 ++-------- .../boot/loader/tools/MainClassFinder.java | 5 +---- .../boot/loader/ClassPathIndexFile.java | 2 +- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java index 6267ef8f851..6a89f6d96da 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java @@ -70,7 +70,7 @@ public enum ApiVersion { private static ApiVersion forType(String type) { if (type.startsWith(MEDIA_TYPE_PREFIX)) { type = type.substring(MEDIA_TYPE_PREFIX.length()); - int suffixIndex = type.indexOf("+"); + int suffixIndex = type.indexOf('+'); type = (suffixIndex != -1) ? type.substring(0, suffixIndex) : type; try { return valueOf(type.toUpperCase()); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java index e44c31e3d28..1ecde55effa 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java @@ -74,10 +74,7 @@ class ProjectGenerator { return true; } // explicit name hasn't been provided for an archive and there is no extension - if (isZipArchive(response) && request.getOutput() != null && !request.getOutput().contains(".")) { - return true; - } - return false; + return isZipArchive(response) && request.getOutput() != null && !request.getOutput().contains("."); } private boolean isZipArchive(ProjectGenerationResponse entity) { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java index 5e12d8476ff..bfbeed9e454 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java @@ -140,10 +140,7 @@ public class DependencyCustomizer { protected boolean canAdd() { for (String path : paths) { try { - if (DependencyCustomizer.this.loader.getResource(path) == null) { - return false; - } - return true; + return DependencyCustomizer.this.loader.getResource(path) != null; } catch (Exception ex) { // swallow exception and continue @@ -166,10 +163,7 @@ public class DependencyCustomizer { protected boolean canAdd() { for (String path : paths) { try { - if (DependencyCustomizer.this.loader.getResource(path) != null) { - return true; - } - return false; + return DependencyCustomizer.this.loader.getResource(path) != null; } catch (Exception ex) { // swallow exception and continue diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index a4488836201..cfe20c14b74 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -381,10 +381,7 @@ public abstract class MainClassFinder { return false; } MainClass other = (MainClass) obj; - if (!this.name.equals(other.name)) { - return false; - } - return true; + return this.name.equals(other.name); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java index ed11b19f01e..e60036340d3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java @@ -54,7 +54,7 @@ final class ClassPathIndexFile { } private String getFolder(String name) { - int lastSlash = name.lastIndexOf("/"); + int lastSlash = name.lastIndexOf('/'); return (lastSlash != -1) ? name.substring(0, lastSlash) : null; } From 03bee839917ce819b1c4056be4231dd7e815a233 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 16 Feb 2020 17:20:48 +0100 Subject: [PATCH 2/2] Update copyright date See gh-20192 --- .../springframework/boot/actuate/endpoint/http/ApiVersion.java | 2 +- .../springframework/boot/cli/command/init/ProjectGenerator.java | 2 +- .../org/springframework/boot/loader/tools/MainClassFinder.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java index 6a89f6d96da..a4531b65d38 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java index 1ecde55effa..63e6922f4d7 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index cfe20c14b74..e65a4a36429 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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.