Browse Source

Make equality checks defensive to null reference

See gh-19540
pull/19905/head
liuhuan 6 years ago committed by Stephane Nicoll
parent
commit
6d8b849361
  1. 4
      spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java
  2. 2
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientBuilderCustomizer.java
  3. 2
      spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LoaderZipEntries.java
  4. 6
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java

4
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java

@ -102,7 +102,7 @@ public abstract class ResourceUtils { @@ -102,7 +102,7 @@ public abstract class ResourceUtils {
List<String> result = new ArrayList<>();
for (Resource resource : resources) {
if (resource.exists()) {
if (resource.getURI().getScheme().equals("file") && resource.getFile().isDirectory()) {
if ("file".equals(resource.getURI().getScheme()) && resource.getFile().isDirectory()) {
result.addAll(getChildFiles(resource));
continue;
}
@ -124,7 +124,7 @@ public abstract class ResourceUtils { @@ -124,7 +124,7 @@ public abstract class ResourceUtils {
}
private static String absolutePath(Resource resource) throws IOException {
if (!resource.getURI().getScheme().equals("file")) {
if (!"file".equals(resource.getURI().getScheme())) {
return resource.getURL().toExternalForm();
}
return resource.getFile().getAbsoluteFile().toURI().toString();

2
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientBuilderCustomizer.java

@ -61,7 +61,7 @@ class RestDocsWebTestClientBuilderCustomizer implements WebTestClientBuilderCust @@ -61,7 +61,7 @@ class RestDocsWebTestClientBuilderCustomizer implements WebTestClientBuilderCust
if (port == null) {
return true;
}
return (scheme.equals("http") && port == 80) || (scheme.equals("https") && port == 443);
return ("http".equals(scheme) && port == 80) || ("https".equals(scheme) && port == 443);
}
}

2
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LoaderZipEntries.java

@ -50,7 +50,7 @@ class LoaderZipEntries { @@ -50,7 +50,7 @@ class LoaderZipEntries {
getClass().getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) {
java.util.zip.ZipEntry entry = loaderJar.getNextEntry();
while (entry != null) {
if (entry.isDirectory() && !entry.getName().equals("META-INF/")) {
if (entry.isDirectory() && !"META-INF/".equals(entry.getName())) {
writeDirectory(new ZipArchiveEntry(entry), zipOutputStream);
writtenDirectoriesSpec.add(entry);
}

6
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java

@ -369,12 +369,12 @@ public class Repackager { @@ -369,12 +369,12 @@ public class Repackager {
@Override
public JarArchiveEntry transform(JarArchiveEntry entry) {
if (entry.getName().equals("META-INF/INDEX.LIST")) {
if ("META-INF/INDEX.LIST".equals(entry.getName())) {
return null;
}
if ((entry.getName().startsWith("META-INF/") && !entry.getName().equals("META-INF/aop.xml")
if ((entry.getName().startsWith("META-INF/") && !"META-INF/aop.xml".equals(entry.getName())
&& !entry.getName().endsWith(".kotlin_module")) || entry.getName().startsWith("BOOT-INF/")
|| entry.getName().equals("module-info.class")) {
|| "module-info.class".equals(entry.getName())) {
return entry;
}
JarArchiveEntry renamedEntry = new JarArchiveEntry(this.namePrefix + entry.getName());

Loading…
Cancel
Save