Make equality checks defensive to null reference

See gh-19540
pull/19905/head
liuhuan 5 years ago committed by Stephane Nicoll
parent e87ed08ef4
commit 6d8b849361

@ -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());

Loading…
Cancel
Save