diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java index 705ad3f88b5..ef0932f450e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java @@ -53,7 +53,7 @@ public class PropertySourcesPlaceholdersResolver implements PlaceholdersResolver @Override public Object resolvePlaceholders(Object value) { - if (value != null && value instanceof String) { + if (value instanceof String) { return this.helper.replacePlaceholders((String) value, this::resolvePlaceholder); } return value; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java index 6cd550949b8..01f5f48319e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java @@ -204,7 +204,7 @@ public class SpringApplicationJsonEnvironmentPostProcessor implements Environmen static JsonPropertyValue get(PropertySource propertySource) { for (String candidate : CANDIDATES) { Object value = propertySource.getProperty(candidate); - if (value != null && value instanceof String && StringUtils.hasLength((String) value)) { + if (value instanceof String && StringUtils.hasLength((String) value)) { return new JsonPropertyValue(propertySource, candidate, (String) value); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java index dd8832cc3ed..cf7307beee1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/Origin.java @@ -44,10 +44,10 @@ public interface Origin { return (Origin) source; } Origin origin = null; - if (source != null && source instanceof OriginProvider) { + if (source instanceof OriginProvider) { origin = ((OriginProvider) source).getOrigin(); } - if (origin == null && source != null && source instanceof Throwable) { + if (origin == null && source instanceof Throwable) { return from(((Throwable) source).getCause()); } return origin; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index 8ffcd04a19b..bbfb5cd1348 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -64,7 +64,7 @@ public class ApplicationPid { if (obj == this) { return true; } - if (obj != null && obj instanceof ApplicationPid) { + if (obj instanceof ApplicationPid) { return ObjectUtils.nullSafeEquals(this.pid, ((ApplicationPid) obj).pid); } return false; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java index 73917e896ff..8c0748e9e11 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java @@ -130,7 +130,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException Throwable error = getError(webRequest); if (error != null) { while (error instanceof ServletException && error.getCause() != null) { - error = ((ServletException) error).getCause(); + error = error.getCause(); } if (this.includeException) { errorAttributes.put("exception", error.getClass().getName()); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java index 40befbc8aa7..87f8f2bc8b9 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java @@ -155,7 +155,7 @@ class SpringApplicationBuilderTests { ClassLoader classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader()); application.resourceLoader(new DefaultResourceLoader(classLoader)); this.context = application.run(); - assertThat(((SpyApplicationContext) this.context).getClassLoader()).isEqualTo(classLoader); + assertThat(this.context.getClassLoader()).isEqualTo(classLoader); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 3abec00e2ed..47fc08b96f3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -306,8 +306,8 @@ class ConfigFileApplicationListenerTests { @Test void defaultPropertyAsFallback() { - this.environment.getPropertySources().addLast( - new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", (Object) "foo"))); + this.environment.getPropertySources() + .addLast(new MapPropertySource("defaultProperties", Collections.singletonMap("my.fallback", "foo"))); this.initializer.postProcessEnvironment(this.environment, this.application); String property = this.environment.getProperty("my.fallback"); assertThat(property).isEqualTo("foo"); @@ -316,7 +316,7 @@ class ConfigFileApplicationListenerTests { @Test void defaultPropertyAsFallbackDuringFileParsing() { this.environment.getPropertySources().addLast(new MapPropertySource("defaultProperties", - Collections.singletonMap("spring.config.name", (Object) "testproperties"))); + Collections.singletonMap("spring.config.name", "testproperties"))); this.initializer.postProcessEnvironment(this.environment, this.application); String property = this.environment.getProperty("the.property"); assertThat(property).isEqualTo("frompropertiesfile"); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java index 2cb0bd12ef5..cbb66a50e6f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java @@ -410,7 +410,7 @@ class ConfigurationPropertyNameTests { @Test void appendWhenElementNameIsNullShouldReturnName() { ConfigurationPropertyName name = ConfigurationPropertyName.of("foo"); - assertThat((Object) name.append((String) null)).isSameAs(name); + assertThat((Object) name.append(null)).isSameAs(name); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index 7747de235d2..defdab81609 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -767,8 +767,7 @@ public abstract class AbstractServletWebServerFactoryTests { this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(false, true), "/hello")); this.webServer.start(); TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory(); - Map contentDecoderMap = Collections.singletonMap("gzip", - (InputStreamFactory) inputStreamFactory); + Map contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory); getResponse(getLocalUrl("/hello"), new HttpComponentsClientHttpRequestFactory( HttpClientBuilder.create().setContentDecoderRegistry(contentDecoderMap).build())); assertThat(inputStreamFactory.wasCompressionUsed()).isTrue(); @@ -975,8 +974,7 @@ public abstract class AbstractServletWebServerFactoryTests { HttpMethod method) throws Exception { String testContent = setUpFactoryForCompression(contentSize, mimeTypes, excludedUserAgents); TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory(); - Map contentDecoderMap = Collections.singletonMap("gzip", - (InputStreamFactory) inputStreamFactory); + Map contentDecoderMap = Collections.singletonMap("gzip", inputStreamFactory); String response = getResponse(getLocalUrl("/test.txt"), method, new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent") .setContentDecoderRegistry(contentDecoderMap).build()));