diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java index 850ce266c81..d335f2209b3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java @@ -182,62 +182,29 @@ public class BuildInfoProperties implements Serializable { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } BuildInfoProperties other = (BuildInfoProperties) obj; - if (this.additionalProperties == null) { - if (other.additionalProperties != null) { - return false; - } - } - else if (!this.additionalProperties.equals(other.additionalProperties)) { - return false; - } - if (this.artifact == null) { - if (other.artifact != null) { - return false; - } - } - else if (!this.artifact.equals(other.artifact)) { - return false; - } - if (this.group == null) { - if (other.group != null) { - return false; - } - } - else if (!this.group.equals(other.group)) { - return false; - } - if (this.name == null) { - if (other.name != null) { - return false; - } - } - else if (!this.name.equals(other.name)) { - return false; - } - if (this.version == null) { - if (other.version != null) { - return false; - } - } - else if (!this.version.equals(other.version)) { - return false; - } - if (this.time == null) { - if (other.time != null) { - return false; - } + boolean result = true; + result = result + && nullSafeEquals(this.additionalProperties, other.additionalProperties); + result = result && nullSafeEquals(this.artifact, other.artifact); + result = result && nullSafeEquals(this.group, other.group); + result = result && nullSafeEquals(this.name, other.name); + result = result && nullSafeEquals(this.version, other.version); + result = result && nullSafeEquals(this.time, other.time); + return result; + } + + private boolean nullSafeEquals(Object o1, Object o2) { + if (o1 == o2) { + return true; } - else if (!this.time.equals(other.time)) { + if (o1 == null || o2 == null) { return false; } - return true; + return (o1.equals(o2)); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index c2166fd8c59..ea4b10259e6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -119,7 +119,6 @@ class BootZipCopyAction implements CopyAction { return () -> true; } - @SuppressWarnings("unchecked") private Spec createExclusionSpec( Spec loaderEntries) { return Specs.union(loaderEntries, this.exclusions); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java index 4152e2a8c14..f42ce7a0ca5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java @@ -88,10 +88,7 @@ public class LaunchScriptConfiguration implements Serializable { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } LaunchScriptConfiguration other = (LaunchScriptConfiguration) obj;