Skip to content

Commit 6d8b849

Browse files
liuhuansnicoll
authored andcommitted
Make equality checks defensive to null reference
See gh-19540
1 parent e87ed08 commit 6d8b849

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private static List<String> getUrlsFromPrefixedWildcardPath(String path, ClassLo
102102
List<String> result = new ArrayList<>();
103103
for (Resource resource : resources) {
104104
if (resource.exists()) {
105-
if (resource.getURI().getScheme().equals("file") && resource.getFile().isDirectory()) {
105+
if ("file".equals(resource.getURI().getScheme()) && resource.getFile().isDirectory()) {
106106
result.addAll(getChildFiles(resource));
107107
continue;
108108
}
@@ -124,7 +124,7 @@ private static List<String> getChildFiles(Resource resource) throws IOException
124124
}
125125

126126
private static String absolutePath(Resource resource) throws IOException {
127-
if (!resource.getURI().getScheme().equals("file")) {
127+
if (!"file".equals(resource.getURI().getScheme())) {
128128
return resource.getURL().toExternalForm();
129129
}
130130
return resource.getFile().getAbsoluteFile().toURI().toString();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private boolean isStandardPort(String scheme, Integer port) {
6161
if (port == null) {
6262
return true;
6363
}
64-
return (scheme.equals("http") && port == 80) || (scheme.equals("https") && port == 443);
64+
return ("http".equals(scheme) && port == 80) || ("https".equals(scheme) && port == 443);
6565
}
6666

6767
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Spec<FileTreeElement> writeTo(ZipArchiveOutputStream zipOutputStream) thr
5050
getClass().getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) {
5151
java.util.zip.ZipEntry entry = loaderJar.getNextEntry();
5252
while (entry != null) {
53-
if (entry.isDirectory() && !entry.getName().equals("META-INF/")) {
53+
if (entry.isDirectory() && !"META-INF/".equals(entry.getName())) {
5454
writeDirectory(new ZipArchiveEntry(entry), zipOutputStream);
5555
writtenDirectoriesSpec.add(entry);
5656
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,12 @@ private RenamingEntryTransformer(String namePrefix) {
369369

370370
@Override
371371
public JarArchiveEntry transform(JarArchiveEntry entry) {
372-
if (entry.getName().equals("META-INF/INDEX.LIST")) {
372+
if ("META-INF/INDEX.LIST".equals(entry.getName())) {
373373
return null;
374374
}
375-
if ((entry.getName().startsWith("META-INF/") && !entry.getName().equals("META-INF/aop.xml")
375+
if ((entry.getName().startsWith("META-INF/") && !"META-INF/aop.xml".equals(entry.getName())
376376
&& !entry.getName().endsWith(".kotlin_module")) || entry.getName().startsWith("BOOT-INF/")
377-
|| entry.getName().equals("module-info.class")) {
377+
|| "module-info.class".equals(entry.getName())) {
378378
return entry;
379379
}
380380
JarArchiveEntry renamedEntry = new JarArchiveEntry(this.namePrefix + entry.getName());

0 commit comments

Comments
 (0)