diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchRestHealthContributorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchRestHealthContributorAutoConfiguration.java index 58cd0f27dac..94987fed1c2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchRestHealthContributorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchRestHealthContributorAutoConfiguration.java @@ -45,7 +45,6 @@ import org.springframework.context.annotation.Configuration; @ConditionalOnBean(RestClient.class) @ConditionalOnEnabledHealthIndicator("elasticsearch") @AutoConfigureAfter(RestClientAutoConfiguration.class) -@SuppressWarnings("deprecation") public class ElasticSearchRestHealthContributorAutoConfiguration extends CompositeHealthContributorConfiguration { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java index 5f998e5fdff..0097d5299a5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java @@ -164,11 +164,11 @@ public final class EndpointRequest { } private EndpointServerWebExchangeMatcher(Class[] endpoints, boolean includeLinks) { - this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks); + this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks); } private EndpointServerWebExchangeMatcher(String[] endpoints, boolean includeLinks) { - this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks); + this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks); } private EndpointServerWebExchangeMatcher(List includes, List excludes, boolean includeLinks) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java index a64b2147b9c..3c5299f3bfd 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java @@ -196,11 +196,11 @@ public final class EndpointRequest { } private EndpointRequestMatcher(Class[] endpoints, boolean includeLinks) { - this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks); + this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks); } private EndpointRequestMatcher(String[] endpoints, boolean includeLinks) { - this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks); + this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks); } private EndpointRequestMatcher(List includes, List excludes, boolean includeLinks) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index 3c3b5be3be8..a1f11dc80fd 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -186,7 +186,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext * @param prefix the prefix * @return the serialized instance */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked" }) private Map safeSerialize(ObjectMapper mapper, Object bean, String prefix) { try { return new HashMap<>(mapper.convertValue(bean, Map.class)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java index c876604baae..14904f1526f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java @@ -162,12 +162,10 @@ public class JerseyEndpointResourceFactory { } } + @SuppressWarnings("unchecked") private Map extractBodyArguments(ContainerRequestContext data) { Map entity = ((ContainerRequest) data).readEntity(Map.class); - if (entity == null) { - return Collections.emptyMap(); - } - return entity; + return (entity != null) ? entity : Collections.emptyMap(); } private Map extractPathParameters(ContainerRequestContext requestContext) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/ClusterEnvironmentBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/ClusterEnvironmentBuilderCustomizer.java index d5f2234a401..aaf567ece89 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/ClusterEnvironmentBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/ClusterEnvironmentBuilderCustomizer.java @@ -20,8 +20,10 @@ import com.couchbase.client.java.env.ClusterEnvironment; /** * Callback interface that can be implemented by beans wishing to customize the - * {@link ClusterEnvironment} via a {@link ClusterEnvironment.Builder} whilst retaining - * default auto-configuration.whilst retaining default auto-configuration. + * {@link ClusterEnvironment} via a + * {@link com.couchbase.client.java.env.ClusterEnvironment.Builder + * ClusterEnvironment.Builder} whilst retaining default auto-configuration.whilst + * retaining default auto-configuration. * * @author Stephane Nicoll * @since 2.3.0 @@ -30,7 +32,8 @@ import com.couchbase.client.java.env.ClusterEnvironment; public interface ClusterEnvironmentBuilderCustomizer { /** - * Customize the {@link ClusterEnvironment.Builder}. + * Customize the {@link com.couchbase.client.java.env.ClusterEnvironment.Builder + * ClusterEnvironment.Builder}. * @param builder the builder to customize */ void customize(ClusterEnvironment.Builder builder); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupport.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupport.java index a529f36a2ac..30330b83fbd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupport.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupport.java @@ -33,6 +33,7 @@ import org.springframework.util.Assert; /** * Base class for setup that is common to MongoDB client factories. * + * @param the mongo client type * @author Christoph Strobl * @author Scott Frederick * @since 2.3.0 diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java index 5c37a2e3dbf..5c1ca7438de 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java @@ -136,8 +136,8 @@ public final class ConnectionFactoryBuilder { static class ConnectionFactoryOptionsInitializer { /** - * Initialize a {@link ConnectionFactoryOptions.Builder} using the specified - * properties. + * Initialize a {@link io.r2dbc.spi.ConnectionFactoryOptions.Builder + * ConnectionFactoryOptions.Builder} using the specified properties. * @param properties the properties to use to initialize the builder * @param embeddedDatabaseConnection the embedded connection to use as a fallback * @return an initialized builder diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java index 01e71a3b5e9..a31aad2c3c2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java @@ -169,6 +169,7 @@ public class UndertowWebServerFactoryCustomizer return (value) -> this.factory.addBuilderCustomizers((builder) -> builder.setSocketOption(option, value)); } + @SuppressWarnings("unchecked") Consumer> forEach(Function, Consumer> function) { return (map) -> map.forEach((key, value) -> { Option option = (Option) NAME_LOOKUP.get(getCanonicalName(key)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java index b356b9fe1df..cb737da3b7c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java @@ -19,9 +19,6 @@ package org.springframework.boot.autoconfigure.web.format; import java.time.format.DateTimeFormatter; import java.time.format.ResolverStyle; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.springframework.format.datetime.DateFormatter; import org.springframework.format.datetime.DateFormatterRegistrar; import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; @@ -49,8 +46,6 @@ public class WebConversionService extends DefaultFormattingConversionService { private static final boolean JSR_354_PRESENT = ClassUtils.isPresent("javax.money.MonetaryAmount", WebConversionService.class.getClassLoader()); - private static final Log logger = LogFactory.getLog(WebConversionService.class); - private final String dateFormat; /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseContainer.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseContainer.java index bf6efae0892..e3afd141d77 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseContainer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseContainer.java @@ -64,6 +64,7 @@ import static org.testcontainers.shaded.org.apache.commons.codec.binary.Base64.e * Temporary copy of TestContainers's Couchbase support until it works against Couchbase * SDK v3. */ +@SuppressWarnings("resource") class CouchbaseContainer extends GenericContainer { public static final String VERSION = "5.5.1"; @@ -198,7 +199,6 @@ class CouchbaseContainer extends GenericContainer { } @Override - @SuppressWarnings({ "unchecked", "ConstantConditions" }) public void stop() { try { stopCluster(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index 66ac0f1a6f9..51a979516de 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -667,6 +667,7 @@ class KafkaAutoConfigurationTests { @Configuration(proxyBeanMethods = false) static class ConsumerFactoryConfiguration { + @SuppressWarnings("unchecked") private final ConsumerFactory consumerFactory = mock(ConsumerFactory.class); @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java index bf49f3c4bcd..dbce629aaf6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java @@ -42,6 +42,7 @@ import static org.mockito.Mockito.verify; /** * Tests for {@link MongoClientFactorySupport}. * + * @param the mongo client type * @author Phillip Webb * @author Andy Wilkinson * @author Stephane Nicoll diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java index 3e3830e59ce..5e8a3f5998a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java @@ -167,10 +167,8 @@ class R2dbcAutoConfigurationTests { this.contextRunner.withPropertyValues("spring.r2dbc.pool.enabled=false", "spring.r2dbc.url:r2dbc:simple://foo", "spring.r2dbc.properties.test=value", "spring.r2dbc.properties.another=2").run((context) -> { SimpleTestConnectionFactory connectionFactory = context.getBean(SimpleTestConnectionFactory.class); - assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("test"))) - .isEqualTo("value"); - assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("another"))) - .isEqualTo("2"); + assertThat(getRequiredOptionsValue(connectionFactory, "test")).isEqualTo("value"); + assertThat(getRequiredOptionsValue(connectionFactory, "another")).isEqualTo("2"); }); } @@ -181,13 +179,15 @@ class R2dbcAutoConfigurationTests { assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class); SimpleTestConnectionFactory connectionFactory = (SimpleTestConnectionFactory) context .getBean(ConnectionPool.class).unwrap(); - assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("test"))) - .isEqualTo("value"); - assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("another"))) - .isEqualTo("2"); + assertThat(getRequiredOptionsValue(connectionFactory, "test")).isEqualTo("value"); + assertThat(getRequiredOptionsValue(connectionFactory, "another")).isEqualTo("2"); }); } + private Object getRequiredOptionsValue(SimpleTestConnectionFactory connectionFactory, String name) { + return connectionFactory.options.getRequiredValue(Option.valueOf(name)); + } + @Test void configureWithoutUrlShouldCreateEmbeddedConnectionPoolByDefault() { this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ConnectionFactory.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java index 3a6bf77c309..cf25c544446 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java @@ -350,7 +350,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests { .run((context) -> { assertThat(context).hasSingleBean(ReactiveJwtDecoder.class); ReactiveJwtDecoder reactiveJwtDecoder = context.getBean(ReactiveJwtDecoder.class); - DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils + DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils .getField(reactiveJwtDecoder, "jwtValidator"); Collection> tokenValidators = (Collection>) ReflectionTestUtils .getField(jwtValidator, "tokenValidators"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java index 14b8fc85abf..e6f666513a0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java @@ -338,7 +338,7 @@ class OAuth2ResourceServerAutoConfigurationTests { .run((context) -> { assertThat(context).hasSingleBean(JwtDecoder.class); JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils + DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils .getField(jwtDecoder, "jwtValidator"); Collection> tokenValidators = (Collection>) ReflectionTestUtils .getField(jwtValidator, "tokenValidators"); diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java index 3c13f620cf0..003b6d2e2ef 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java @@ -376,6 +376,7 @@ public abstract class AbstractApplicationContextRunner consumer) { withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> { try (A context = createAssertableContext()) { diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureRule.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureRule.java index 4297fe33c88..50536bfa0e3 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureRule.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureRule.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.hamcrest.Matcher; -import org.junit.Assert; +import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -70,7 +70,7 @@ public class OutputCaptureRule implements TestRule, CapturedOutput { try { if (!OutputCaptureRule.this.matchers.isEmpty()) { String output = OutputCaptureRule.this.delegate.toString(); - Assert.assertThat(output, allOf(OutputCaptureRule.this.matchers)); + MatcherAssert.assertThat(output, allOf(OutputCaptureRule.this.matchers)); } } finally { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/generic/GenericBuilderProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/generic/GenericBuilderProperties.java index bb8db7e3c5b..440b860883f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/generic/GenericBuilderProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/generic/GenericBuilderProperties.java @@ -30,6 +30,7 @@ public class GenericBuilderProperties> { return this.number; } + @SuppressWarnings("unchecked") public T setNumber(int number) { this.number = number; return (T) this; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/method/SingleConstructorMethodConfig.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/method/SingleConstructorMethodConfig.java index e2d23226c54..583005d082b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/method/SingleConstructorMethodConfig.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/method/SingleConstructorMethodConfig.java @@ -24,6 +24,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties; * * @author Stephane Nicoll */ +@SuppressWarnings("unused") public class SingleConstructorMethodConfig { @ConfigurationProperties(prefix = "foo") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/specific/TwoConstructorsClassConstructorBindingExample.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/specific/TwoConstructorsClassConstructorBindingExample.java index 6738f15d814..295e06cc32f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/specific/TwoConstructorsClassConstructorBindingExample.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/specific/TwoConstructorsClassConstructorBindingExample.java @@ -24,6 +24,7 @@ import org.springframework.boot.configurationsample.MetaConstructorBinding; * @author Stephane Nicoll */ @MetaConstructorBinding +@SuppressWarnings("unused") public class TwoConstructorsClassConstructorBindingExample { private String name; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index fdae3fcfdeb..22c418154fe 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -240,10 +240,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { || (this.systemPropertyVariables != null && !this.systemPropertyVariables.isEmpty()); } - private boolean hasEnvVariables() { - return (this.environmentVariables != null && !this.environmentVariables.isEmpty()); - } - private boolean hasWorkingDirectorySet() { return this.workingDirectory != null; } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java index ebc21fb1df8..07c5e317e23 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java @@ -41,6 +41,7 @@ class JacksonJsonParserTests extends AbstractJsonParserTests { } @Test + @SuppressWarnings("unchecked") void instanceWithSpecificObjectMapper() throws IOException { ObjectMapper objectMapper = spy(new ObjectMapper()); new JacksonJsonParser(objectMapper).parseMap("{}"); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackConfigurationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackConfigurationTests.java index 1c2391ec33a..c46f5af25ec 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackConfigurationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackConfigurationTests.java @@ -77,7 +77,7 @@ class LogbackConfigurationTests { Appender appender = context.getLogger("ROOT").getAppender("FILE"); assertThat(appender).isInstanceOf(RollingFileAppender.class); RollingPolicy rollingPolicy = ((RollingFileAppender) appender).getRollingPolicy(); - String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern(); + String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern(); assertThat(fileNamePattern).endsWith("spring.log.%d{yyyy-MM-dd}.%i.gz"); } @@ -90,7 +90,7 @@ class LogbackConfigurationTests { Appender appender = context.getLogger("ROOT").getAppender("FILE"); assertThat(appender).isInstanceOf(RollingFileAppender.class); RollingPolicy rollingPolicy = ((RollingFileAppender) appender).getRollingPolicy(); - String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern(); + String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern(); assertThat(fileNamePattern).endsWith("my.log.%d{yyyyMMdd}.%i.gz"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java index f4a8b172cac..cfd1d7a1e6f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java @@ -37,6 +37,7 @@ import org.apache.catalina.startup.Tomcat; import org.apache.catalina.valves.RemoteIpValve; import org.apache.coyote.ProtocolHandler; import org.apache.coyote.http11.AbstractHttp11Protocol; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -46,7 +47,6 @@ import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFac import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests; import org.springframework.boot.web.server.PortInUseException; import org.springframework.boot.web.server.Shutdown; -import org.springframework.boot.web.server.Ssl; import org.springframework.boot.web.server.WebServerException; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.util.SocketUtils; @@ -55,7 +55,6 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -75,14 +74,16 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto return new TomcatReactiveWebServerFactory(0); } + @Override @Test @Disabled("gh-19702") - void compressionOfResponseToGetRequest() { + protected void compressionOfResponseToGetRequest() { } + @Override @Test @Disabled("gh-19702") - void compressionOfResponseToPostRequest() { + protected void compressionOfResponseToPostRequest() { } @Test @@ -248,18 +249,9 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto }); } - @Test - void sslWithInvalidAliasFailsDuringStartup() { - String keyStore = "classpath:test.jks"; - String keyPassword = "password"; - AbstractReactiveWebServerFactory factory = getFactory(); - Ssl ssl = new Ssl(); - ssl.setKeyStore(keyStore); - ssl.setKeyPassword(keyPassword); - ssl.setKeyAlias("test-alias-404"); - factory.setSsl(ssl); - assertThatThrownBy(() -> factory.getWebServer(new EchoHandler()).start()) - .isInstanceOf(WebServerException.class); + @Override + protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) { + assertThatExceptionOfType(WebServerException.class).isThrownBy(call); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index 9780ac9f443..2dbd873fd79 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -65,18 +65,16 @@ import org.apache.http.impl.client.HttpClients; import org.apache.jasper.servlet.JspServlet; import org.apache.tomcat.JarScanFilter; import org.apache.tomcat.JarScanType; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.springframework.boot.testsupport.system.CapturedOutput; -import org.springframework.boot.testsupport.web.servlet.ExampleServlet; import org.springframework.boot.web.server.PortInUseException; import org.springframework.boot.web.server.Shutdown; -import org.springframework.boot.web.server.Ssl; import org.springframework.boot.web.server.WebServerException; -import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory; import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests; import org.springframework.core.io.ByteArrayResource; @@ -93,7 +91,6 @@ import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -555,14 +552,9 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory this.webServer.start(); } - @Test - void sslWithInvalidAliasFailsDuringStartup() { - AbstractServletWebServerFactory factory = getFactory(); - Ssl ssl = getSsl(null, "password", "test-alias-404", "src/test/resources/test.jks"); - factory.setSsl(ssl); - ServletRegistrationBean registration = new ServletRegistrationBean<>( - new ExampleServlet(true, false), "/hello"); - assertThatThrownBy(() -> factory.getWebServer(registration).start()).isInstanceOf(WebServerException.class); + @Override + protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) { + assertThatExceptionOfType(WebServerException.class).isThrownBy(call); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java index d77f79384cb..dc551f96d8a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java @@ -43,6 +43,7 @@ import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslProvider; import io.netty.handler.ssl.util.InsecureTrustManagerFactory; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -178,8 +179,11 @@ public abstract class AbstractReactiveWebServerFactoryTests { ssl.setKeyPassword(keyPassword); ssl.setKeyAlias("test-alias-404"); factory.setSsl(ssl); - assertThatThrownBy(() -> factory.getWebServer(new EchoHandler()).start()) - .hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'"); + assertThatSslWithInvalidAliasCallFails(() -> factory.getWebServer(new EchoHandler()).start()); + } + + protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) { + assertThatThrownBy(call).hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'"); } protected ReactorClientHttpConnector buildTrustAllSslConnector() { @@ -280,7 +284,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { } @Test - void compressionOfResponseToGetRequest() { + protected void compressionOfResponseToGetRequest() { WebClient client = prepareCompressionTest(); ResponseEntity response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class)) .block(Duration.ofSeconds(30)); @@ -288,7 +292,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { } @Test - void compressionOfResponseToPostRequest() { + protected void compressionOfResponseToPostRequest() { WebClient client = prepareCompressionTest(); ResponseEntity response = client.post().exchange().flatMap((res) -> res.toEntity(Void.class)) .block(Duration.ofSeconds(30)); 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 6a493abde5c..e67f16dd88a 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 @@ -95,6 +95,7 @@ import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.TrustStrategy; import org.apache.jasper.EmbeddedServletOptions; import org.apache.jasper.servlet.JspServlet; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; @@ -469,8 +470,12 @@ public abstract class AbstractServletWebServerFactoryTests { factory.setSsl(ssl); ServletRegistrationBean registration = new ServletRegistrationBean<>( new ExampleServlet(true, false), "/hello"); - assertThatThrownBy(() -> factory.getWebServer(registration).start()) - .hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'"); + ThrowingCallable call = () -> factory.getWebServer(registration).start(); + assertThatSslWithInvalidAliasCallFails(call); + } + + protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) { + assertThatThrownBy(call).hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'"); } @Test