diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java index 30ffb63b7e..ab9652cbfb 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java @@ -56,7 +56,7 @@ class OverrideAutoConfigurationContextCustomizerFactory implements ContextCustom @Override public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); + return (obj != null) && (obj.getClass() == getClass()); } @Override diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java index 5872a7b912..09f9d1987d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java @@ -71,8 +71,8 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && getClass() == obj.getClass() - && this.filters.equals(((TypeExcludeFiltersContextCustomizer) obj).filters)); + return (obj != null) && (getClass() == obj.getClass()) + && this.filters.equals(((TypeExcludeFiltersContextCustomizer) obj).filters); } @Override diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index ac62c80a80..03a5911fb0 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java @@ -57,8 +57,8 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && getClass() == obj.getClass() - && this.propertySource.equals(((PropertyMappingContextCustomizer) obj).propertySource)); + return (obj != null) && (getClass() == obj.getClass()) + && this.propertySource.equals(((PropertyMappingContextCustomizer) obj).propertySource); } @Override diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java index fb9fa3110f..6b1139ac30 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java @@ -37,10 +37,7 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - if (obj == this) { - return true; - } - return obj != null && getClass() == obj.getClass(); + return (obj != null) && (getClass() == obj.getClass()); } @Override diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java index b6245fd04e..785d24f401 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java @@ -80,7 +80,7 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa @Override public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); + return (obj != null) && (getClass() == obj.getClass()); } @Override diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java index 8af6dcd647..f35a610df8 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java @@ -208,8 +208,8 @@ class OutputCapture implements CapturedOutput { } private static PrintStream getSystemStream(PrintStream printStream) { - if (printStream instanceof PrintStreamCapture) { - return ((PrintStreamCapture) printStream).getParent(); + while (printStream instanceof PrintStreamCapture) { + printStream = ((PrintStreamCapture) printStream).getParent(); } return printStream; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java index f8edb210e8..5d7c7b1a05 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java @@ -78,7 +78,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); + return (obj != null) && (obj.getClass() == getClass()); } @Override diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java index 9d63e0973b..c2ab1dde7f 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java @@ -79,7 +79,7 @@ class WebTestClientContextCustomizer implements ContextCustomizer { @Override public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); + return (obj != null) && (obj.getClass() == getClass()); } @Override