diff --git a/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java index 583e0dd21be6..e3afc9f2e9de 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java @@ -38,6 +38,7 @@ public class DeployedPlugin implements Plugin { public static final String GENERATE_POM_TASK_NAME = "generatePomFileForMavenPublication"; @Override + @SuppressWarnings("deprecation") public void apply(Project project) { project.getPlugins().apply(MavenPublishPlugin.class); project.getPlugins().apply(MavenRepositoryPlugin.class); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/ExtractResources.java b/buildSrc/src/main/java/org/springframework/boot/build/ExtractResources.java index 09cae37037b6..78473cec471f 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/ExtractResources.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/ExtractResources.java @@ -28,6 +28,7 @@ import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; +import org.gradle.api.Task; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.OutputDirectory; diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java index cc8f01f765df..4c56ae74a76a 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,6 +84,7 @@ public String getMilestone() { } @TaskAction + @SuppressWarnings("deprecation") void upgradeDependencies() { GitHubRepository repository = createGitHub().getRepository(this.bom.getUpgrade().getGitHub().getOrganization(), this.bom.getUpgrade().getGitHub().getRepository()); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java index fe92d8357107..a1979ac1d351 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java @@ -241,10 +241,6 @@ boolean matches(EndpointId endpointId) { return this.matchesAll || this.endpointIds.contains(endpointId); } - static EndpointPatterns forExposure(EndpointExposure exposure) { - return (exposure != null) ? new EndpointPatterns(exposure.getDefaultIncludes()) : null; - } - } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java index 019fdbc38795..059bedda4aa1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo @Override @Deprecated + @SuppressWarnings("deprecation") public long getLastModified(HttpServletRequest request, Object handler) { Optional adapter = getAdapter(handler); return adapter.map((handlerAdapter) -> handlerAdapter.getLastModified(request, handler)).orElse(0L); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java index 4086a519b21e..ce85bb61f013 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,26 +125,27 @@ void matchWhenRequestHasSuffixShouldBeNull() { private RequestMatchResult getMatchResult(String servletPath, boolean isPatternParser) { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServletPath(servletPath); - AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(); - if (isPatternParser) { - context.register(WebMvcConfiguration.class); - } - else { - context.register(PathMatcherWebMvcConfiguration.class); - } - context.register(TestEndpointConfiguration.class); - context.refresh(); - WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class); - try { - // Setup request attributes - ServletRequestPathUtils.parseAndCache(request); - // Trigger initLookupPath - bean.getHandler(request); - } - catch (Exception ex) { - throw new RuntimeException(ex); + try (AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext()) { + if (isPatternParser) { + context.register(WebMvcConfiguration.class); + } + else { + context.register(PathMatcherWebMvcConfiguration.class); + } + context.register(TestEndpointConfiguration.class); + context.refresh(); + WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class); + try { + // Setup request attributes + ServletRequestPathUtils.parseAndCache(request); + // Trigger initLookupPath + bean.getHandler(request); + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + return bean.match(request, "/spring"); } - return bean.match(request, "/spring"); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/ClientResourcesBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/ClientResourcesBuilderCustomizer.java index 1a9fde48bc83..d81b3eceb0cc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/ClientResourcesBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/ClientResourcesBuilderCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,11 @@ package org.springframework.boot.autoconfigure.data.redis; import io.lettuce.core.resource.ClientResources; +import io.lettuce.core.resource.ClientResources.Builder; /** * Callback interface that can be implemented by beans wishing to customize the - * {@link ClientResources} via a {@link ClientResources.Builder} whilst retaining default + * {@link ClientResources} via a {@link Builder} whilst retaining default * auto-configuration. * * @author Stephane Nicoll @@ -29,9 +30,9 @@ public interface ClientResourcesBuilderCustomizer { /** - * Customize the {@link ClientResources.Builder}. + * Customize the {@link Builder}. * @param clientResourcesBuilder the builder to customize */ - void customize(ClientResources.Builder clientResourcesBuilder); + void customize(Builder clientResourcesBuilder); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/RestClientBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/RestClientBuilderCustomizer.java index 685929d908c7..712166f2f2c9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/RestClientBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/RestClientBuilderCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.boot.autoconfigure.elasticsearch; import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.config.RequestConfig.Builder; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.elasticsearch.client.RestClientBuilder; @@ -52,11 +53,11 @@ default void customize(HttpAsyncClientBuilder builder) { } /** - * Customize the {@link RequestConfig.Builder}. + * Customize the {@link Builder}. * @param builder the builder * @since 2.3.0 */ - default void customize(RequestConfig.Builder builder) { + default void customize(Builder builder) { } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 96da586a59ce..4892198113be 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -325,10 +325,6 @@ private void configureJavaMigrations(FluentConfiguration flyway, List { AbstractKafkaListenerContainerFactory kafkaListenerContainerFactory = (AbstractKafkaListenerContainerFactory) context 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 b274b7392d8e..e0f51ce2ee13 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 @@ -154,7 +154,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOidcIssuerUri() throws I .getBean(SupplierReactiveJwtDecoder.class); Mono reactiveJwtDecoderSupplier = (Mono) ReflectionTestUtils .getField(supplierReactiveJwtDecoder, "jwtDecoderMono"); - ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(); + reactiveJwtDecoderSupplier.block(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(1); @@ -177,7 +177,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOidcRfc8414IssuerUri() t .getBean(SupplierReactiveJwtDecoder.class); Mono reactiveJwtDecoderSupplier = (Mono) ReflectionTestUtils .getField(supplierReactiveJwtDecoder, "jwtDecoderMono"); - ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(); + reactiveJwtDecoderSupplier.block(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(2); @@ -200,7 +200,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOAuthIssuerUri() throws .getBean(SupplierReactiveJwtDecoder.class); Mono reactiveJwtDecoderSupplier = (Mono) ReflectionTestUtils .getField(supplierReactiveJwtDecoder, "jwtDecoderMono"); - ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(); + reactiveJwtDecoderSupplier.block(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(3); @@ -417,7 +417,6 @@ void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfProper }); } - @SuppressWarnings("unchecked") @Test void autoConfigurationShouldConfigureIssuerAndAudienceJwtValidatorIfPropertyProvided() throws Exception { this.server = new MockWebServer(); @@ -487,7 +486,6 @@ void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndIssue }); } - @SuppressWarnings("unchecked") @Test void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndPublicKey() throws Exception { this.server = new MockWebServer(); 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 f5cd7a315ed1..ebce6261c449 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 @@ -150,7 +150,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOidcIssuerUri() throws E SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class); Supplier jwtDecoderSupplier = (Supplier) ReflectionTestUtils .getField(supplierJwtDecoderBean, "jwtDecoderSupplier"); - JwtDecoder jwtDecoder = jwtDecoderSupplier.get(); + jwtDecoderSupplier.get(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(2); @@ -172,7 +172,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOidcRfc8414IssuerUri() t SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class); Supplier jwtDecoderSupplier = (Supplier) ReflectionTestUtils .getField(supplierJwtDecoderBean, "jwtDecoderSupplier"); - JwtDecoder jwtDecoder = jwtDecoderSupplier.get(); + jwtDecoderSupplier.get(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(3); @@ -195,7 +195,7 @@ void autoConfigurationShouldConfigureResourceServerUsingOAuthIssuerUri() throws SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class); Supplier jwtDecoderSupplier = (Supplier) ReflectionTestUtils .getField(supplierJwtDecoderBean, "jwtDecoderSupplier"); - JwtDecoder jwtDecoder = jwtDecoderSupplier.get(); + jwtDecoderSupplier.get(); }); // The last request is to the JWK Set endpoint to look up the algorithm assertThat(this.server.getRequestCount()).isEqualTo(4); @@ -434,7 +434,6 @@ void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfProper }); } - @SuppressWarnings("unchecked") @Test void autoConfigurationShouldConfigureAudienceAndIssuerJwtValidatorIfPropertyProvided() throws Exception { this.server = new MockWebServer(); @@ -503,7 +502,6 @@ private void validateDelegates(String issuerUri, Collection { + @SuppressWarnings("unused") private ServletContext servletContext; @Override diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/AbstractMockBeanOnGenericTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/AbstractMockBeanOnGenericTests.java index 76ae636c5749..ab7d34ba659c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/AbstractMockBeanOnGenericTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/AbstractMockBeanOnGenericTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,15 @@ /** * Tests for {@link MockBean} with abstract class and generics. * + * @param type of thing + * @param type of something * @author Madhura Bhave */ @SpringBootTest(classes = AbstractMockBeanOnGenericTests.TestConfiguration.class) abstract class AbstractMockBeanOnGenericTests, U extends AbstractMockBeanOnGenericTests.Something> { @Autowired + @SuppressWarnings("unused") private T thing; @MockBean diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java index bf5fc8fd4d51..6ebdfb8fa757 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java @@ -451,11 +451,6 @@ public void onUpdate(ProgressUpdateEvent event) { } } - String getCapturedDigest() { - Assert.hasText(this.digest, "No digest found"); - return this.digest; - } - } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java index 66aab11e7bfa..51b7dd01812a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,8 @@ public void writeTo(OutputStream outputStream) throws IOException { FileCopyUtils.copy((byte[]) this.content, outputStream); } else if (this.content instanceof File) { - FileCopyUtils.copy(new FileInputStream((File) this.content), outputStream); + InputStream inputStream = new FileInputStream((File) this.content); + FileCopyUtils.copy(inputStream, outputStream); } else { throw new IllegalStateException("Unknown content type"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java index 329b7ce90c35..218c83b281ae 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ public void repackage(File destination, Libraries libraries, LaunchScript launch public void repackage(File destination, Libraries libraries, LaunchScript launchScript, FileTime lastModifiedTime) throws IOException { Assert.isTrue(destination != null && !destination.isDirectory(), "Invalid destination"); - Layout layout = getLayout(); // get layout early + getLayout(); // get layout early destination = destination.getAbsoluteFile(); File source = getSource(); if (isAlreadyPackaged() && source.equals(destination)) { 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 12186dd49405..f7728b03a9a9 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 @@ -248,7 +248,6 @@ private boolean hasWorkingDirectorySet() { return this.workingDirectory != null; } - @SuppressWarnings("deprecation") private void run(String startClassName) throws MojoExecutionException, MojoFailureException { boolean fork = isFork(); this.project.getProperties().setProperty("_spring.boot.fork.enabled", Boolean.toString(fork)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java index 705acb0868dc..3b23f953cbc6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java @@ -82,7 +82,6 @@ public class StopMojo extends AbstractMojo { private boolean skip; @Override - @SuppressWarnings("deprecation") public void execute() throws MojoExecutionException, MojoFailureException { if (this.skip) { getLog().debug("skipping stop as per configuration."); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/ValidationBindHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/ValidationBindHandler.java index df33378fe51e..4789e9434ada 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/ValidationBindHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/ValidationBindHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -149,12 +149,9 @@ private class ValidationResult extends BeanPropertyBindingResult { private final ConfigurationPropertyName name; - private final Object target; - protected ValidationResult(ConfigurationPropertyName name, Object target) { super(target, null); this.name = name; - this.target = target; } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataTests.java index 8575438ad1aa..fb5d507fd693 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,6 +75,7 @@ void getDeprecatedOptionsReturnsCopyOfOptions() { @Test @Deprecated + @SuppressWarnings("deprecation") void getDeprecatedOptionsWhenUsingPropertySourceOptionsThrowsException() { MapPropertySource source = new MapPropertySource("test", Collections.emptyMap()); PropertySourceOptions propertySourceOptions = (propertySource) -> Options.NONE; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index c9d208a842a0..79cd1b677726 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -477,7 +477,6 @@ void loadWhenDotsInSystemEnvironmentPropertiesShouldBind() { } @Test - @SuppressWarnings("unchecked") void loadWhenEnvironmentPrefixSetShouldBind() { MutablePropertySources sources = this.context.getEnvironment().getPropertySources(); sources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index 96e719c7af4a..1da829f82961 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -439,6 +439,7 @@ private void availableClasses(String... classNames) { */ static class Nested { + @SuppressWarnings("unused") private static final Log logger = LogFactory.getLog(Nested.class); } diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java index 76bce51592c2..5185e5a7b62f 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java @@ -81,7 +81,8 @@ void executableJarApp() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); assertLabelsMatchManifestAttributes(config); @@ -109,8 +110,9 @@ void executableJarAppWithAdditionalArgs() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withCommand("--server.port=9090") - .withExposedPorts(9090)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withCommand("--server.port=9090"); + container.withExposedPorts(9090); container.waitingFor(Wait.forHttp("/test")).start(); } finally { @@ -125,14 +127,16 @@ void executableJarAppBuiltTwiceWithCaching() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); container.stop(); } this.gradleBuild.expectDeprecationMessages("BOM table is deprecated"); result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); } finally { @@ -148,7 +152,8 @@ void bootDistZipJarApp() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName, "assemble", "bootDistZip"); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); ImageAssertions.assertThat(config).buildMetadata((metadata) -> { @@ -181,7 +186,8 @@ void plainDistZipJarApp() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName, "assemble", "bootDistZip"); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); ImageAssertions.assertThat(config).buildMetadata((metadata) -> { @@ -216,7 +222,8 @@ void executableWarApp() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); assertLabelsMatchManifestAttributes(config); @@ -245,7 +252,8 @@ void plainWarApp() throws Exception { ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); BuildResult result = buildImage(imageName); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { + try (GenericContainer container = new GenericContainer<>(imageName)) { + container.withExposedPorts(8080); container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); ImageAssertions.assertThat(config).buildMetadata((metadata) -> { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast3ApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast3ApplicationTests.java index 3d26388a8387..b55194cb4d83 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast3ApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast3ApplicationTests.java @@ -38,9 +38,6 @@ class SampleHazelcast3ApplicationTests { @Autowired private CacheManager cacheManager; - @Autowired - private CountryRepository countryRepository; - @Test void cacheManagerIsUsingHazelcast() { assertThat(this.cacheManager).isInstanceOf(HazelcastCacheManager.class); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/src/test/java/smoketest/hazelcast4/SampleHazelcast4ApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/src/test/java/smoketest/hazelcast4/SampleHazelcast4ApplicationTests.java index 4f81f68a5dfd..f16bda437573 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/src/test/java/smoketest/hazelcast4/SampleHazelcast4ApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/src/test/java/smoketest/hazelcast4/SampleHazelcast4ApplicationTests.java @@ -38,9 +38,6 @@ class SampleHazelcast4ApplicationTests { @Autowired private CacheManager cacheManager; - @Autowired - private CountryRepository countryRepository; - @Test void cacheManagerIsUsingHazelcast() { assertThat(this.cacheManager).isInstanceOf(HazelcastCacheManager.class); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java index a48093d441e3..ff84a1e6805d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -81,12 +82,13 @@ private String getBasicAuth() { return "Basic " + Base64.getEncoder().encodeToString("user:password".getBytes()); } - @SuppressWarnings("unchecked") private ResponseEntity> getSessions() { HttpHeaders headers = getHeaders(null); RequestEntity request = new RequestEntity<>(headers, HttpMethod.GET, URI.create("/actuator/sessions?username=user")); - return (ResponseEntity>) (ResponseEntity) this.restTemplate.exchange(request, Map.class); + ParameterizedTypeReference> stringObjectMap = new ParameterizedTypeReference>() { + }; + return this.restTemplate.exchange(request, stringObjectMap); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java index 035bc5283600..c989d223e50a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -94,12 +95,13 @@ private String getBasicAuth() { return "Basic " + Base64.getEncoder().encodeToString("user:password".getBytes()); } - @SuppressWarnings("unchecked") private ResponseEntity> getSessions() { HttpHeaders headers = getHeaders(null); RequestEntity request = new RequestEntity<>(headers, HttpMethod.GET, URI.create("/actuator/sessions?username=user")); - return (ResponseEntity>) (ResponseEntity) this.restTemplate.exchange(request, Map.class); + ParameterizedTypeReference> stringObjectMap = new ParameterizedTypeReference>() { + }; + return this.restTemplate.exchange(request, stringObjectMap); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-mongo/src/test/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-mongo/src/test/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java index a99500bd5bd2..ae6ffc255519 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-mongo/src/test/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-mongo/src/test/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.testsupport.testcontainers.DockerImageNames; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -83,10 +84,11 @@ private RequestEntity getRequestEntity(URI uri) { return new RequestEntity<>(headers, HttpMethod.GET, uri); } - @SuppressWarnings("unchecked") private ResponseEntity> getSessions() { RequestEntity request = getRequestEntity(URI.create("/actuator/sessions?username=user")); - return (ResponseEntity>) (ResponseEntity) this.restTemplate.exchange(request, Map.class); + ParameterizedTypeReference> stringObjectMap = new ParameterizedTypeReference>() { + }; + return this.restTemplate.exchange(request, stringObjectMap); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-redis/src/test/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-redis/src/test/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java index 8863197968bf..f65481b146e4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-redis/src/test/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-redis/src/test/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.testsupport.testcontainers.RedisContainer; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -81,10 +82,11 @@ private RequestEntity getRequestEntity(URI uri) { return new RequestEntity<>(headers, HttpMethod.GET, uri); } - @SuppressWarnings("unchecked") private ResponseEntity> getSessions() { RequestEntity request = getRequestEntity(URI.create("/actuator/sessions?username=user")); - return (ResponseEntity>) (ResponseEntity) this.restTemplate.exchange(request, Map.class); + ParameterizedTypeReference> stringObjectMap = new ParameterizedTypeReference>() { + }; + return this.restTemplate.exchange(request, stringObjectMap); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/src/main/webapp/WEB-INF/web.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/src/main/webapp/WEB-INF/web.xml index f36e80423ec8..4edd3072260c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/src/main/webapp/WEB-INF/web.xml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/src/main/webapp/WEB-INF/web.xml @@ -22,10 +22,4 @@ / - - - - -