Commit 6d8b8493 authored by liuhuan's avatar liuhuan Committed by Stephane Nicoll

Make equality checks defensive to null reference

See gh-19540
parent e87ed08e
......@@ -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 {
}
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();
......
......@@ -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);
}
}
......@@ -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);
}
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment