From 1006b386e4fa3cbc9595f6001843d55f8cb3f28e Mon Sep 17 00:00:00 2001 From: Spring Builds Date: Thu, 19 May 2022 12:42:28 +0000 Subject: [PATCH 001/161] Next development version (v2.7.1-SNAPSHOT) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2b147a00489a..ee93bc516b5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.7.0-SNAPSHOT +version=2.7.1-SNAPSHOT org.gradle.caching=true org.gradle.parallel=true From 0d78323b600b89ffe8b5f0d55e74f49cd43539c7 Mon Sep 17 00:00:00 2001 From: Liuzh Date: Fri, 20 May 2022 08:37:33 +0800 Subject: [PATCH 002/161] Resolve errors in layers.xsd Update `layer-*.xsd` files with following fixes: - Rename to - Rename to See gh-31126 --- .../spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd | 4 ++-- .../spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd index 57eac0d6b9f5..464ef34d316a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd @@ -78,14 +78,14 @@ - + - + - + - + Date: Thu, 19 May 2022 17:34:57 -0700 Subject: [PATCH 003/161] Polish "Resolve errors in layers.xsd" Validate loaded `layer.xml` files against the XSD and additionally update `` sub elements to have a 'minOccurs' of 0. See gh-31126 --- .../spring-boot-maven-plugin/build.gradle | 17 ++++++++-- .../boot/maven/AbstractPackagerMojo.java | 3 +- .../boot/maven/CustomLayersProvider.java | 32 ++++++++++++++++++- .../src/main/xsd/layers-2.3.xsd | 6 ++-- .../src/main/xsd/layers-2.4.xsd | 8 ++--- .../src/main/xsd/layers-2.5.xsd | 8 ++--- .../boot/maven/CustomLayersProviderTests.java | 3 +- 7 files changed, 61 insertions(+), 16 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle index a8e7b881fb10..f220f448ebd9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle @@ -64,6 +64,11 @@ dependencies { versionProperties(project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "effectiveBom")) } +ext { + versionElements = version.split("\\.") + xsdVersion = versionElements[0] + "." + versionElements[1] +} + syncDocumentationSourceForAsciidoctor { from(documentPluginGoals) { into "asciidoc/goals" @@ -71,6 +76,9 @@ syncDocumentationSourceForAsciidoctor { } sourceSets { + main { + output.dir("${buildDir}/generated/resources/xsd", builtBy: "xsdResources") + } intTest { output.dir("${buildDir}/generated-resources", builtBy: "extractVersionProperties") } @@ -78,8 +86,7 @@ sourceSets { tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) { doFirst { - def versionEl = version.split("\\.") - attributes "spring-boot-xsd-version": versionEl[0] + '.' + versionEl[1] + attributes "spring-boot-xsd-version" : project.ext.xsdVersion } } @@ -129,6 +136,12 @@ task zip(type: Zip) { } } +task xsdResources(type: Sync) { + from "src/main/xsd/layers-${project.ext.xsdVersion}.xsd" + into "${buildDir}/generated/resources/xsd/org/springframework/boot/maven" + rename { fileName -> "layers.xsd" } +} + prepareMavenBinaries { versions "3.8.1", "3.6.3", "3.5.4" } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java index 3ce19bf4c105..82ff6455e40f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.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. @@ -171,6 +171,7 @@ private CustomLayers getCustomLayers(File configuration) { private Document getDocumentIfAvailable(File xmlFile) throws Exception { InputSource inputSource = new InputSource(new FileInputStream(xmlFile)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(inputSource); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java index 5d01b34caa95..2889520bd400 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.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. @@ -16,16 +16,24 @@ package org.springframework.boot.maven; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; +import javax.xml.XMLConstants; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; import org.springframework.boot.loader.tools.Layer; import org.springframework.boot.loader.tools.Library; @@ -45,6 +53,7 @@ class CustomLayersProvider { CustomLayers getLayers(Document document) { + validate(document); Element root = document.getDocumentElement(); List> applicationSelectors = getApplicationSelectors(root); List> librarySelectors = getLibrarySelectors(root); @@ -52,6 +61,27 @@ CustomLayers getLayers(Document document) { return new CustomLayers(layers, applicationSelectors, librarySelectors); } + private void validate(Document document) { + Schema schema = loadSchema(); + try { + Validator validator = schema.newValidator(); + validator.validate(new DOMSource(document)); + } + catch (SAXException | IOException ex) { + throw new IllegalStateException("Invalid layers.xml configuration", ex); + } + } + + private Schema loadSchema() { + try { + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + return factory.newSchema(getClass().getResource("layers.xsd")); + } + catch (SAXException ex) { + throw new IllegalStateException("Unable to load layers XSD"); + } + } + private List> getApplicationSelectors(Element root) { return getSelectors(root, "application", (element) -> getSelector(element, ApplicationContentFilter::new)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.3.xsd b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.3.xsd index 01eca01439c9..c5c68586516d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.3.xsd +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.3.xsd @@ -6,9 +6,9 @@ - - - + + + diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd index 464ef34d316a..20219b9bd8b1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd @@ -6,9 +6,9 @@ - - - + + + @@ -92,7 +92,7 @@ ]]> - + diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd index 464ef34d316a..20219b9bd8b1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd @@ -6,9 +6,9 @@ - - - + + + @@ -92,7 +92,7 @@ ]]> - + diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/CustomLayersProviderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/CustomLayersProviderTests.java index 5e5bceaea24f..e9b9f2bc49ac 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/CustomLayersProviderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/CustomLayersProviderTests.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. @@ -97,6 +97,7 @@ private Document getDocument(String resourceName) throws Exception { ClassPathResource resource = new ClassPathResource(resourceName); InputSource inputSource = new InputSource(resource.getInputStream()); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); return documentBuilder.parse(inputSource); } From 5fb96076bd3f1a408441f00b65ef236096619d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 21 May 2022 00:36:13 -0500 Subject: [PATCH 004/161] Use Bellsoft JDK in CI See gh-31139 --- ci/images/get-jdk-url.sh | 8 ++++---- ci/scripts/detect-jdk-updates.sh | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 73d0a553686f..d0148a8a3438 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -3,16 +3,16 @@ set -e case "$1" in java8) - echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u332-b09/OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/8u332+9/bellsoft-jdk8u332+9-linux-amd64.tar.gz" ;; java11) - echo "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.15_10.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15+10/bellsoft-jdk11.0.15+10-linux-amd64.tar.gz" ;; java17) - echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.3%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.3_7.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64.tar.gz" ;; java18) - echo "https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.1%2B10/OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64.tar.gz" ;; *) echo $"Unknown java version" diff --git a/ci/scripts/detect-jdk-updates.sh b/ci/scripts/detect-jdk-updates.sh index 3d67c7773ea6..70955482bbd7 100755 --- a/ci/scripts/detect-jdk-updates.sh +++ b/ci/scripts/detect-jdk-updates.sh @@ -9,19 +9,19 @@ trap 'report_error $? $LINENO' ERR case "$JDK_VERSION" in java8) - BASE_URL="https://api.adoptium.net/v3/assets/feature_releases/8/ga" + BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=8" ISSUE_TITLE="Upgrade Java 8 version in CI image" ;; java11) - BASE_URL="https://api.adoptium.net/v3/assets/feature_releases/11/ga" + BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=11" ISSUE_TITLE="Upgrade Java 11 version in CI image" ;; java17) - BASE_URL="https://api.adoptium.net/v3/assets/feature_releases/17/ga" + BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=17" ISSUE_TITLE="Upgrade Java 17 version in CI image" ;; java18) - BASE_URL="https://api.adoptium.net/v3/assets/feature_releases/18/ga" + BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=18" ISSUE_TITLE="Upgrade Java 18 version in CI image" ;; *) @@ -29,8 +29,8 @@ case "$JDK_VERSION" in exit 1; esac -response=$( curl -s ${BASE_URL}\?architecture\=x64\&heap_size\=normal\&image_type\=jdk\&jvm_impl\=hotspot\&os\=linux\&sort_order\=DESC\&vendor\=adoptium ) -latest=$( jq -r '.[0].binaries[0].package.link' <<< "$response" ) +response=$( curl -s ${BASE_URL}\&arch\=x86\&bitness\=64\&bundle-type\=jdk\&os\=linux\&package-type\=tar.gz\&version-modifier\=latest ) +latest=$( jq -r '.[0].downloadUrl' <<< "$response" ) if [[ ${latest} = "null" || ${latest} = "" ]]; then echo "Could not parse JDK response: $response" exit 1; From 24dc525127a4cd9fa7392f7455211a02f9b1c06d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 23 May 2022 12:49:09 +0100 Subject: [PATCH 005/161] Fix conditions on auto-configured WebMvcMetricsFilter Closes gh-31150 --- .../WebMvcMetricsAutoConfiguration.java | 3 +- .../WebMvcMetricsAutoConfigurationTests.java | 65 +++++++++++++++++-- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java index 078f4cfbf222..23ab645bfbaf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java @@ -41,6 +41,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; @@ -80,7 +81,7 @@ public DefaultWebMvcTagsProvider webMvcTagsProvider(ObjectProvider webMvcMetricsFilter(MeterRegistry registry, WebMvcTagsProvider tagsProvider) { ServerRequest request = this.properties.getWeb().getServer().getRequest(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java index 70dd128b3fa4..5eb2d5c56f8f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java @@ -122,12 +122,32 @@ void filterRegistrationHasExpectedDispatcherTypesAndOrder() { } @Test - void filterRegistrationBacksOff() { - this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(FilterRegistrationBean.class); - assertThat(context.getBean(FilterRegistrationBean.class)) - .isSameAs(context.getBean("testWebMvcMetricsFilter")); - }); + void filterRegistrationBacksOffWithAnotherWebMvcMetricsFilterRegistration() { + this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterRegistrationConfiguration.class) + .run((context) -> { + assertThat(context).hasSingleBean(FilterRegistrationBean.class); + assertThat(context.getBean(FilterRegistrationBean.class)) + .isSameAs(context.getBean("testWebMvcMetricsFilter")); + }); + } + + @Test + void filterRegistrationBacksOffWithAnotherWebMvcMetricsFilter() { + this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterConfiguration.class) + .run((context) -> assertThat(context).doesNotHaveBean(FilterRegistrationBean.class) + .hasSingleBean(WebMvcMetricsFilter.class)); + } + + @Test + void filterRegistrationDoesNotBackOffWithOtherFilterRegistration() { + this.contextRunner.withUserConfiguration(TestFilterRegistrationConfiguration.class) + .run((context) -> assertThat(context).hasBean("testFilter").hasBean("webMvcMetricsFilter")); + } + + @Test + void filterRegistrationDoesNotBackOffWithOtherFilter() { + this.contextRunner.withUserConfiguration(TestFilterConfiguration.class) + .run((context) -> assertThat(context).hasBean("testFilter").hasBean("webMvcMetricsFilter")); } @Test @@ -258,7 +278,7 @@ public Iterable getLongRequestTags(HttpServletRequest request, Object handl } @Configuration(proxyBeanMethods = false) - static class TestWebMvcMetricsFilterConfiguration { + static class TestWebMvcMetricsFilterRegistrationConfiguration { @Bean @SuppressWarnings("unchecked") @@ -268,4 +288,35 @@ FilterRegistrationBean testWebMvcMetricsFilter() { } + @Configuration(proxyBeanMethods = false) + static class TestWebMvcMetricsFilterConfiguration { + + @Bean + WebMvcMetricsFilter testWebMvcMetricsFilter() { + return new WebMvcMetricsFilter(null, null, null, null); + } + + } + + @Configuration(proxyBeanMethods = false) + static class TestFilterRegistrationConfiguration { + + @Bean + @SuppressWarnings("unchecked") + FilterRegistrationBean testFilter() { + return mock(FilterRegistrationBean.class); + } + + } + + @Configuration(proxyBeanMethods = false) + static class TestFilterConfiguration { + + @Bean + Filter testFilter() { + return mock(Filter.class); + } + + } + } From 07047e7e8530b688fefa88ad9a97fb3a041f9b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 21 May 2022 01:14:33 -0500 Subject: [PATCH 006/161] Add .sdkmanrc with latest java version See gh-31141 --- .sdkmanrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .sdkmanrc diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 000000000000..51f59b27450b --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1,3 @@ +# Enable auto-env through the sdkman_auto_env config +# Add key=value pairs of SDKs to use below +java=8.0.332-librca From 154c84ffe205d79ead8d836fe949f23d9e39b3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 21 May 2022 01:03:09 -0500 Subject: [PATCH 007/161] Add package-info for o.s.b.a.a.metrics.graphql See gh-31140 --- .../metrics/graphql/package-info.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/package-info.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/package-info.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/package-info.java new file mode 100644 index 000000000000..471595d95f3f --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for Spring GraphQL metrics. + */ +package org.springframework.boot.actuate.autoconfigure.metrics.graphql; From 3e7bd582a3965cb6ed3f77ba6b33707af45b01bc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 25 May 2022 12:41:06 +0100 Subject: [PATCH 008/161] Upgrade to Spring Java Format 0.0.33 Closes gh-31166 --- buildSrc/build.gradle | 2 -- buildSrc/config/checkstyle/checkstyle.xml | 9 +++++++++ buildSrc/gradle.properties | 2 +- buildSrc/settings.gradle | 7 ------- .../boot/testsupport/junit/package-info.java | 20 +++++++++++++++++++ src/checkstyle/checkstyle-suppressions.xml | 8 +++++--- 6 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 buildSrc/config/checkstyle/checkstyle.xml create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/package-info.java diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index c5516567b98b..a4cf101356df 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -33,8 +33,6 @@ dependencies { } checkstyle { - def archive = configurations.checkstyle.filter { it.name.startsWith("spring-javaformat-checkstyle")} - config = resources.text.fromArchiveEntry(archive, "io/spring/javaformat/checkstyle/checkstyle.xml") toolVersion = 8.11 } diff --git a/buildSrc/config/checkstyle/checkstyle.xml b/buildSrc/config/checkstyle/checkstyle.xml new file mode 100644 index 000000000000..1ad50d8fcb84 --- /dev/null +++ b/buildSrc/config/checkstyle/checkstyle.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 6a758322d20d..f09112a67b98 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -1 +1 @@ -javaFormatVersion=0.0.31 +javaFormatVersion=0.0.33 diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index b3efa0794004..4cdfcbf3bd5a 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -3,11 +3,4 @@ pluginManagement { mavenCentral() gradlePluginPortal() } - resolutionStrategy { - eachPlugin { - if (requested.id.id == "io.spring.javaformat") { - useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}" - } - } - } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/package-info.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/package-info.java new file mode 100644 index 000000000000..eb52274b6394 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * General support classes for testing with JUnit. + */ +package org.springframework.boot.testsupport.junit; diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 16d5f0d188e5..a721a91e7c12 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -17,14 +17,14 @@ - + - + - + @@ -49,7 +49,9 @@ + + From cbf42dea1497a4f20aa02578601fbfddc5e214ad Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 26 May 2022 13:59:03 +0100 Subject: [PATCH 009/161] Update deprecation messages to change removal version from 2.8 to 3.0 Closes gh-30903 --- .../actuate/autoconfigure/OnEndpointElementCondition.java | 4 ++-- .../endpoint/expose/IncludeExcludeEndpointFilter.java | 8 ++++---- .../properties/ConfigurationPropertiesReportEndpoint.java | 2 +- .../boot/actuate/env/EnvironmentEndpoint.java | 4 ++-- .../AbstractRabbitListenerContainerFactoryConfigurer.java | 6 +++--- .../DirectRabbitListenerContainerFactoryConfigurer.java | 4 ++-- .../boot/autoconfigure/amqp/RabbitTemplateConfigurer.java | 6 +++--- .../SimpleRabbitListenerContainerFactoryConfigurer.java | 4 ++-- .../autoconfigure/batch/BatchDataSourceInitializer.java | 4 ++-- ...precatedReactiveElasticsearchRestClientProperties.java | 4 ++-- .../DeprecatedElasticsearchRestClientProperties.java | 4 ++-- .../integration/IntegrationDataSourceInitializer.java | 4 ++-- .../autoconfigure/quartz/QuartzDataSourceInitializer.java | 4 ++-- .../session/JdbcSessionDataSourceInitializer.java | 4 ++-- .../autoconfigure/web/reactive/WebFluxProperties.java | 8 ++++---- .../boot/cli/compiler/grape/AetherGrapeEngine.java | 2 +- .../boot/cli/compiler/grape/AetherGrapeEngineFactory.java | 2 +- .../context/runner/AbstractApplicationContextRunner.java | 6 +++--- .../gradle/tasks/application/CreateBootStartScripts.java | 2 +- .../boot/SpringApplicationRunListener.java | 6 +++--- .../boot/builder/SpringApplicationBuilder.java | 4 ++-- .../boot/context/event/ApplicationReadyEvent.java | 4 ++-- .../boot/context/event/ApplicationStartedEvent.java | 4 ++-- .../boot/jdbc/AbstractDataSourceInitializer.java | 4 ++-- .../boot/jdbc/DataSourceInitializationMode.java | 4 ++-- .../boot/logging/log4j2/Log4J2LoggingSystem.java | 4 ++-- .../orm/jpa/hibernate/SpringPhysicalNamingStrategy.java | 4 ++-- 27 files changed, 58 insertions(+), 58 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java index a9b9a3f7dd06..ff0cb0e655c2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.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. @@ -85,7 +85,7 @@ protected ConditionOutcome getDefaultOutcome(ConditionContext context, Annotatio * Return the default outcome that should be used. * @param context the condition context * @return the default outcome - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #getDefaultOutcome(ConditionContext, AnnotationAttributes)} */ @Deprecated 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 fa55c55b2b6b..fe92d8357107 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 @@ -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. @@ -58,7 +58,7 @@ public class IncludeExcludeEndpointFilter> implem * @param environment the environment containing the properties * @param prefix the property prefix to bind * @param defaultIncludes the default {@code includes} to use when none are specified. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #IncludeExcludeEndpointFilter(Class, Environment, String, String[])} */ @Deprecated @@ -103,7 +103,7 @@ public IncludeExcludeEndpointFilter(Class endpointType, Collection in * @param include the include patterns * @param exclude the exclude patterns * @param defaultIncludes the default {@code includes} to use when none are specified. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #IncludeExcludeEndpointFilter(Class, Environment, String, String[])} */ @Deprecated @@ -174,7 +174,7 @@ private boolean isExcluded(EndpointId endpointId) { /** * Default include patterns that can be used. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of {@link EndpointExposure}. + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of {@link EndpointExposure}. */ @Deprecated public enum DefaultIncludes { 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 bff7fc6d4fdc..f1545096eb56 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 @@ -169,7 +169,7 @@ private ObjectMapper getObjectMapper() { * {@link ConfigurationProperties @ConfigurationProperties} objects into a {@link Map} * structure. * @param mapper the object mapper - * @deprecated since 2.6 for removal in 2.8 in favor of + * @deprecated since 2.6 for removal in 3.0 in favor of * {@link #configureJsonMapper(com.fasterxml.jackson.databind.json.JsonMapper.Builder)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java index 79644791c2e5..a261deeda4c6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.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. @@ -198,7 +198,7 @@ private void extract(String root, Map> map, PropertySo * @param key the name to sanitize * @param value the value to sanitize * @return the sanitized value - * @deprecated since 2.6.0 for removal in 2.8.0 as sanitization should be internal to + * @deprecated since 2.6.0 for removal in 3.0.0 as sanitization should be internal to * the class */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java index 9877d08b95e4..cf4ecb2fbe65 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.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. @@ -49,7 +49,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer r /** * Set the {@link RabbitProperties} to use. * @param rabbitProperties the {@link RabbitProperties} - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #AbstractRabbitListenerContainerFactoryConfigurer(RabbitProperties)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/DirectRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/DirectRabbitListenerContainerFactoryConfigurer.java index 1789511d067f..014069413245 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/DirectRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/DirectRabbitListenerContainerFactoryConfigurer.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. @@ -33,7 +33,7 @@ public final class DirectRabbitListenerContainerFactoryConfigurer /** * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #DirectRabbitListenerContainerFactoryConfigurer(RabbitProperties)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java index f775b5d02104..08d47f5dd13f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.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. @@ -41,7 +41,7 @@ public class RabbitTemplateConfigurer { /** * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #RabbitTemplateConfigurer(RabbitProperties)} */ @Deprecated @@ -81,7 +81,7 @@ public void setRetryTemplateCustomizers(List retr /** * Set the {@link RabbitProperties} to use. * @param rabbitProperties the {@link RabbitProperties} - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #RabbitTemplateConfigurer(RabbitProperties)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java index 7406a1b5e6c3..b9767e60419b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.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. @@ -33,7 +33,7 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer /** * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #SimpleRabbitListenerContainerFactoryConfigurer(RabbitProperties)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java index 27cd382507e7..8f1b5c1d5834 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.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,7 +30,7 @@ * @author Dave Syer * @author Vedran Pavic * @since 1.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link BatchDataSourceScriptDatabaseInitializer} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java index cb879c531ab2..a8d7ac370c3e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.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. @@ -29,7 +29,7 @@ * Deprecated configuration properties for Elasticsearch Reactive REST clients. * * @author Brian Clozel - * @deprecated since 2.6.0 for removal in 2.8.0 + * @deprecated since 2.6.0 for removal in 3.0.0 */ @Deprecated @ConfigurationProperties(prefix = "spring.data.elasticsearch.client.reactive") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java index 373bc00c60ef..3019af3bde2a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.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,7 +28,7 @@ * Deprecated configuration properties for Elasticsearch REST clients. * * @author Brian Clozel - * @deprecated since 2.6.0 for removal in 2.8.0. + * @deprecated since 2.6.0 for removal in 3.0.0. */ @ConfigurationProperties(prefix = "spring.elasticsearch.rest") @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java index 7f2663d13917..a6f09f6f44b0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.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,7 +28,7 @@ * * @author Vedran Pavic * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link IntegrationDataSourceScriptDatabaseInitializer} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java index 512d5f181174..728c519246b2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.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. @@ -29,7 +29,7 @@ * * @author Vedran Pavic * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link QuartzDataSourceScriptDatabaseInitializer} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java index f855c5263728..6f2eb6ee38dd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.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,7 +28,7 @@ * * @author Vedran Pavic * @since 1.4.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link JdbcSessionDataSourceScriptDatabaseInitializer} */ @Deprecated diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java index 001a902cc69f..d85e567dea80 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.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. @@ -127,7 +127,7 @@ public void setDateTime(String dateTime) { /** * Session properties. * - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@code server.reactive.session}. */ @Deprecated @@ -145,7 +145,7 @@ public Cookie getCookie() { /** * Session cookie properties. * - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link org.springframework.boot.web.server.Cookie}. */ @Deprecated @@ -169,7 +169,7 @@ public void setSameSite(SameSite sameSite) { /** * SameSite values. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link org.springframework.boot.web.server.Cookie.SameSite}. */ @Deprecated diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index 012b311b07e9..b8a3de9caef1 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -32,7 +32,7 @@ * @author Andy Wilkinson * @author Phillip Webb * @since 1.0.0 - * @deprecated since 2.5.9 for removal in 2.8.0 in favor of + * @deprecated since 2.5.9 for removal in 3.0.0 in favor of * {@link MavenResolverGrapeEngine} */ @Deprecated diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java index 5465051e8f4d..1f695ae4afbd 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java @@ -40,7 +40,7 @@ * * @author Andy Wilkinson * @since 1.0.0 - * @deprecated since 2.5.9 for removal in 2.8.0 in favor of + * @deprecated since 2.5.9 for removal in 3.0.0 in favor of * {@link MavenResolverGrapeEngineFactory} */ @Deprecated 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 073e109a8b90..e03cd6652a91 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 @@ -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 abstract class AbstractApplicationContextRunner configuration, * @param parent the parent * @param beanRegistrations the bean registrations * @param configurations the configuration - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #AbstractApplicationContextRunner(Supplier, Function)} */ @Deprecated diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/application/CreateBootStartScripts.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/application/CreateBootStartScripts.java index 2fd040e7c8d4..051376976ad3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/application/CreateBootStartScripts.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/application/CreateBootStartScripts.java @@ -25,7 +25,7 @@ * * @author Andy Wilkinson * @since 2.0.0 - * @deprecated since 2.5.10 for removal in 2.8.0 in favor of {@link CreateStartScripts}. + * @deprecated since 2.5.10 for removal in 3.0.0 in favor of {@link CreateStartScripts}. */ @Deprecated public class CreateBootStartScripts extends CreateStartScripts { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index feb92d0bcaf2..7b8df166509b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.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. @@ -90,7 +90,7 @@ default void started(ConfigurableApplicationContext context, Duration timeTaken) * ApplicationRunners} have not been called. * @param context the application context. * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #started(ConfigurableApplicationContext, Duration)} */ @Deprecated @@ -116,7 +116,7 @@ default void ready(ConfigurableApplicationContext context, Duration timeTaken) { * {@link ApplicationRunner ApplicationRunners} have been called. * @param context the application context. * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #ready(ConfigurableApplicationContext, Duration)} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index ac18433f34b4..2b08f2bae305 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.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. @@ -108,7 +108,7 @@ public SpringApplicationBuilder(ResourceLoader resourceLoader, Class... sourc * @param sources the sources * @return the {@link SpringApplication} instance * @since 1.1.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #createSpringApplication(ResourceLoader, Class...)} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationReadyEvent.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationReadyEvent.java index 9e7b89ee44ba..84bc131ddca5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationReadyEvent.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationReadyEvent.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. @@ -44,7 +44,7 @@ public class ApplicationReadyEvent extends SpringApplicationEvent { * @param application the current application * @param args the arguments the application is running with * @param context the context that was being created - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #ApplicationReadyEvent(SpringApplication, String[], ConfigurableApplicationContext, Duration)} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationStartedEvent.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationStartedEvent.java index 0ff27b2c6a27..8f781a8a5385 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationStartedEvent.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationStartedEvent.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. @@ -43,7 +43,7 @@ public class ApplicationStartedEvent extends SpringApplicationEvent { * @param application the current application * @param args the arguments the application is running with * @param context the context that was being created - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #ApplicationStartedEvent(SpringApplication, String[], ConfigurableApplicationContext, Duration)} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java index fa23d5c703e2..7048de290f5b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.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. @@ -35,7 +35,7 @@ * @author Vedran Pavic * @author Stephane Nicoll * @since 1.5.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link DataSourceScriptDatabaseInitializer} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceInitializationMode.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceInitializationMode.java index 27672ee984b5..929128c13cd2 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceInitializationMode.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceInitializationMode.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. @@ -25,7 +25,7 @@ * @author Stephane Nicoll * @since 2.0.0 * @see AbstractDataSourceInitializer - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link DatabaseInitializationMode} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index 8dba1b2e7a38..6242ace3ca8e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.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. @@ -197,7 +197,7 @@ protected void loadConfiguration(LoggingInitializationContext initializationCont * Load the configuration from the given {@code location}. * @param location the location * @param logFile log file configuration - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link #loadConfiguration(String, LogFile, List)} */ @Deprecated diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java index 6937f7b67f3b..655f2fac2792 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.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,7 +30,7 @@ * @author Phillip Webb * @author Madhura Bhave * @since 1.4.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * @deprecated since 2.6.0 for removal in 3.0.0 in favor of * {@link CamelCaseToUnderscoresNamingStrategy} */ @Deprecated From ee45fd2fc8855e2428e23690331925d45a2d81f5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 26 May 2022 14:24:55 +0100 Subject: [PATCH 010/161] Remove redundant throws declarations from internal APIs Closes gh-31176 --- ...eckClasspathForProhibitedDependencies.java | 3 +-- .../boot/build/mavenplugin/MavenExec.java | 2 +- .../build/bom/BomPluginIntegrationTests.java | 2 +- ...nalDependenciesPluginIntegrationTests.java | 2 +- .../TestFailuresPluginIntegrationTests.java | 10 +++++----- .../audit/AuditAutoConfiguration.java | 6 +++--- .../jersey/JerseyEndpointResourceFactory.java | 19 +++++++------------ ...rtiesReportEndpointSerializationTests.java | 6 +++--- .../cache/HazelcastCacheConfiguration.java | 8 +++----- .../ArtemisEmbeddedServerConfiguration.java | 6 +++--- .../EmbeddedLdapAutoConfiguration.java | 4 ++-- .../jta/AtomikosJtaConfiguration.java | 4 ++-- ...10WebSocketServletWebServerCustomizer.java | 5 ++--- ...aSourceScriptDatabaseInitializerTests.java | 2 +- .../jmx/ParentAwareNamingStrategyTests.java | 9 ++++----- .../LiquibaseAutoConfigurationTests.java | 2 +- .../web/ServerPropertiesTests.java | 8 ++++---- .../grape/MavenResolverGrapeEngine.java | 5 ++--- .../tests/DevToolsIntegrationTests.java | 5 ++--- .../OptionalLiveReloadServer.java | 4 ++-- .../boot/devtools/restart/Restarter.java | 12 ++++++------ .../OptionalLiveReloadServerTests.java | 2 +- .../boot/devtools/restart/RestarterTests.java | 2 +- .../MyRestClientTests.java | 4 ++-- .../withoutdb/MyRepositoryTests.java | 4 ++-- .../server/ExampleEndpoint.java | 4 ++-- .../jmx/MyJmxTests.java | 5 ++--- .../springwebfluxtests/MyControllerTests.java | 4 ++-- .../utilities/testresttemplate/MyTests.java | 4 ++-- .../RestDocsTestExecutionListener.java | 4 ++-- ...cyInjectionTestExecutionListenerTests.java | 4 ++-- .../context/SpringBootContextLoaderTests.java | 2 +- ...ClassModeBeforeMethodIntegrationTests.java | 4 ++-- ...tingBeanWithQualifierIntegrationTests.java | 2 +- ...ClassModeBeforeMethodIntegrationTests.java | 2 +- .../mockito/SpyBeanWithJdkProxyTests.java | 2 +- .../build/BuildpackCoordinatesTests.java | 12 ++++++------ .../platform/io/FilePermissionsTests.java | 6 +++--- ...gurationMetadataRepositoryJsonBuilder.java | 4 ++-- .../bundling/AbstractBootArchiveTests.java | 17 ++++++----------- .../loader/tools/AbstractPackagerTests.java | 4 ++-- .../loader/tools/MainClassFinderTests.java | 5 ++--- .../boot/loader/tools/TestJarFile.java | 8 ++++---- .../loader/jar/CentralDirectoryEndRecord.java | 4 ++-- .../boot/maven/JarIntegrationTests.java | 5 ++--- .../boot/maven/WarIntegrationTests.java | 5 ++--- .../springframework/boot/maven/StartMojo.java | 4 ++-- .../springframework/boot/maven/StopMojo.java | 6 +++--- .../tomcat/TomcatEmbeddedContext.java | 5 ++--- .../SpringApplicationShutdownHookTests.java | 2 +- .../ConfigurationPropertyNameTests.java | 4 ++-- .../DurationToStringConverterTests.java | 4 ++-- .../convert/PeriodToStringConverterTests.java | 4 ++-- ...rrentlyInCreationFailureAnalyzerTests.java | 6 +++--- .../TomcatServletWebServerFactoryTests.java | 3 +-- ...AbstractReactiveWebServerFactoryTests.java | 8 ++------ .../AbstractServletWebServerFactoryTests.java | 10 +++------- .../smoketest/atmosphere/ChatService.java | 4 ++-- .../SampleAtmosphereApplication.java | 4 ++-- .../batch/SampleBatchApplication.java | 6 +++--- .../SampleParentContextApplication.java | 4 ++-- ...mpleIntegrationParentApplicationTests.java | 4 ++-- .../CorsSampleActuatorApplicationTests.java | 6 +++--- .../SampleMethodSecurityApplication.java | 4 ++-- .../webservices/endpoint/HolidayEndpoint.java | 9 ++------- .../websocket/jetty/snake/SnakeTimer.java | 2 +- .../websocket/jetty10/snake/SnakeTimer.java | 4 ++-- .../websocket/tomcat/snake/SnakeTimer.java | 2 +- .../websocket/undertow/snake/SnakeTimer.java | 2 +- 69 files changed, 157 insertions(+), 193 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java index f0ea6caa8af7..fa84f09755ef 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java @@ -16,7 +16,6 @@ package org.springframework.boot.build.classpath; -import java.io.IOException; import java.util.TreeSet; import java.util.stream.Collectors; @@ -52,7 +51,7 @@ public FileCollection getClasspath() { } @TaskAction - public void checkForProhibitedDependencies() throws IOException { + public void checkForProhibitedDependencies() { TreeSet prohibited = this.classpath.getResolvedConfiguration().getResolvedArtifacts().stream() .map((artifact) -> artifact.getModuleVersion().getId()).filter(this::prohibited) .map((id) -> id.getGroup() + ":" + id.getName()).collect(Collectors.toCollection(TreeSet::new)); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java index 0536e69c0f73..4a0a6b8d7bbe 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java @@ -43,7 +43,7 @@ public class MavenExec extends JavaExec { private File projectDir; - public MavenExec() throws IOException { + public MavenExec() { setClasspath(mavenConfiguration(getProject())); args("--batch-mode"); setMain("org.apache.maven.cli.MavenCli"); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java index 075db3749a38..6bc78ebc584d 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java @@ -45,7 +45,7 @@ class BomPluginIntegrationTests { private File buildFile; @BeforeEach - void setup(@TempDir File projectDir) throws IOException { + void setup(@TempDir File projectDir) { this.projectDir = projectDir; this.buildFile = new File(this.projectDir, "build.gradle"); } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java index fa43a615d31d..6f9afc4bf9c3 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java @@ -41,7 +41,7 @@ class OptionalDependenciesPluginIntegrationTests { private File buildFile; @BeforeEach - void setup(@TempDir File projectDir) throws IOException { + void setup(@TempDir File projectDir) { this.projectDir = projectDir; this.buildFile = new File(this.projectDir, "build.gradle"); } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java index 38dd5b4de601..b0e11fbee556 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java @@ -44,12 +44,12 @@ class TestFailuresPluginIntegrationTests { private File projectDir; @BeforeEach - void setup(@TempDir File projectDir) throws IOException { + void setup(@TempDir File projectDir) { this.projectDir = projectDir; } @Test - void singleProject() throws IOException { + void singleProject() { createProject(this.projectDir); BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) .withArguments("build").withPluginClasspath().buildAndFail(); @@ -59,7 +59,7 @@ void singleProject() throws IOException { } @Test - void multiProject() throws IOException { + void multiProject() { createMultiProjectBuild(); BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) .withArguments("build").withPluginClasspath().buildAndFail(); @@ -69,7 +69,7 @@ void multiProject() throws IOException { } @Test - void multiProjectContinue() throws IOException { + void multiProjectContinue() { createMultiProjectBuild(); BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) .withArguments("build", "--continue").withPluginClasspath().buildAndFail(); @@ -81,7 +81,7 @@ void multiProjectContinue() throws IOException { } @Test - void multiProjectParallel() throws IOException { + void multiProjectParallel() { createMultiProjectBuild(); BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) .withArguments("build", "--parallel", "--stacktrace").withPluginClasspath().buildAndFail(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java index 7af9e5f4e37a..db9083f5fa0c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -53,14 +53,14 @@ public AuditListener auditListener(AuditEventRepository auditEventRepository) { @Bean @ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent") @ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class) - public AuthenticationAuditListener authenticationAuditListener() throws Exception { + public AuthenticationAuditListener authenticationAuditListener() { return new AuthenticationAuditListener(); } @Bean @ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent") @ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class) - public AuthorizationAuditListener authorizationAuditListener() throws Exception { + public AuthorizationAuditListener authorizationAuditListener() { return new AuthorizationAuditListener(); } 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 dfa775a73fca..cf769a6ed210 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 @@ -240,21 +240,16 @@ private Response convertToJaxRsResponse(Object response, String httpMethod) { Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT; return Response.status(status).build(); } - try { - if (!(response instanceof WebEndpointResponse)) { - return Response.status(Status.OK).entity(convertIfNecessary(response)).build(); - } - WebEndpointResponse webEndpointResponse = (WebEndpointResponse) response; - return Response.status(webEndpointResponse.getStatus()) - .header("Content-Type", webEndpointResponse.getContentType()) - .entity(convertIfNecessary(webEndpointResponse.getBody())).build(); - } - catch (IOException ex) { - return Response.status(Status.INTERNAL_SERVER_ERROR).build(); + if (!(response instanceof WebEndpointResponse)) { + return Response.status(Status.OK).entity(convertIfNecessary(response)).build(); } + WebEndpointResponse webEndpointResponse = (WebEndpointResponse) response; + return Response.status(webEndpointResponse.getStatus()) + .header("Content-Type", webEndpointResponse.getContentType()) + .entity(convertIfNecessary(webEndpointResponse.getBody())).build(); } - private Object convertIfNecessary(Object body) throws IOException { + private Object convertIfNecessary(Object body) { for (Function converter : BODY_CONVERTERS) { body = converter.apply(body); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointSerializationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointSerializationTests.java index db963815e54b..798ff711899b 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointSerializationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointSerializationTests.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. @@ -249,7 +249,7 @@ void hikariDataSourceConfigurationPropertiesBeanCanBeSerialized() { @Test @SuppressWarnings("unchecked") - void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() throws IOException { + void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() { ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> { ConfigurableEnvironment environment = context.getEnvironment(); environment.getPropertySources().addFirst(new MapPropertySource("test", @@ -267,7 +267,7 @@ void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() throws IOExcept @Test @SuppressWarnings("unchecked") - void endpointResponseUsesPlaceholderForComplexValueAsPropertyValue() throws IOException { + void endpointResponseUsesPlaceholderForComplexValueAsPropertyValue() { ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> { ConfigurableEnvironment environment = context.getEnvironment(); environment.getPropertySources().addFirst(new MapPropertySource("test", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastCacheConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastCacheConfiguration.java index c78cf732dc9e..569d03e0738d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastCacheConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.cache; -import java.io.IOException; - import com.hazelcast.core.HazelcastInstance; import com.hazelcast.spring.cache.HazelcastCacheManager; @@ -50,8 +48,8 @@ class HazelcastCacheConfiguration { @Bean - HazelcastCacheManager cacheManager(CacheManagerCustomizers customizers, HazelcastInstance existingHazelcastInstance) - throws IOException { + HazelcastCacheManager cacheManager(CacheManagerCustomizers customizers, + HazelcastInstance existingHazelcastInstance) { HazelcastCacheManager cacheManager = new HazelcastCacheManager(existingHazelcastInstance); return customizers.customize(cacheManager); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java index 336b87c695ca..1c1841a55a80 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.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. @@ -65,8 +65,8 @@ org.apache.activemq.artemis.core.config.Configuration artemisConfiguration() { @Bean(initMethod = "start", destroyMethod = "stop") @ConditionalOnMissingBean EmbeddedActiveMQ embeddedActiveMq(org.apache.activemq.artemis.core.config.Configuration configuration, - JMSConfiguration jmsConfiguration, ObjectProvider configurationCustomizers) - throws Exception { + JMSConfiguration jmsConfiguration, + ObjectProvider configurationCustomizers) { for (JMSQueueConfiguration queueConfiguration : jmsConfiguration.getQueueConfigurations()) { String queueName = queueConfiguration.getName(); configuration.addAddressConfiguration( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java index 8abb907c1e67..fc3adccafc64 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.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. @@ -127,7 +127,7 @@ private void setSchema(InMemoryDirectoryServerConfig config, Resource resource) } } - private void importLdif(ApplicationContext applicationContext) throws LDAPException { + private void importLdif(ApplicationContext applicationContext) { String location = this.embeddedProperties.getLdif(); if (StringUtils.hasText(location)) { try { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.java index 393494c0a232..45060c2870e8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.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. @@ -82,7 +82,7 @@ private String getLogBaseDir(JtaProperties jtaProperties) { @Bean(initMethod = "init", destroyMethod = "close") @ConditionalOnMissingBean(TransactionManager.class) - UserTransactionManager atomikosTransactionManager(UserTransactionService userTransactionService) throws Exception { + UserTransactionManager atomikosTransactionManager(UserTransactionService userTransactionService) { UserTransactionManager manager = new UserTransactionManager(); manager.setStartupTransactionService(false); manager.setForceShutdown(true); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/Jetty10WebSocketServletWebServerCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/Jetty10WebSocketServletWebServerCustomizer.java index c378d6683d02..f8376cc07f16 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/Jetty10WebSocketServletWebServerCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/Jetty10WebSocketServletWebServerCustomizer.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. @@ -77,8 +77,7 @@ private void ensureWebSocketComponents(Server server, ServletContext servletCont ReflectionUtils.invokeMethod(ensureWebSocketComponents, null, server, servletContext); } - private void ensureContainer(Class container, ServletContext servletContext) - throws ClassNotFoundException { + private void ensureContainer(Class container, ServletContext servletContext) { Method ensureContainer = ReflectionUtils.findMethod(container, "ensureContainer", ServletContext.class); ReflectionUtils.invokeMethod(ensureContainer, null, servletContext); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java index 35548abe8bcb..4ac56d5d18ed 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java @@ -64,7 +64,7 @@ void getSettingsWithPlatformDoesNotTouchDataSource() { @ParameterizedTest @EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE, names = { "FIREBIRD", "GAE", "HANA", "INFORMIX", "JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" }) - void batchSchemaCanBeLocated(DatabaseDriver driver) throws IOException, SQLException { + void batchSchemaCanBeLocated(DatabaseDriver driver) throws SQLException { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); BatchProperties properties = new BatchProperties(); DataSource dataSource = mock(DataSource.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/ParentAwareNamingStrategyTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/ParentAwareNamingStrategyTests.java index 5f0531971b2b..f16b8324de59 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/ParentAwareNamingStrategyTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/ParentAwareNamingStrategyTests.java @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.jmx; -import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.junit.jupiter.api.Test; @@ -38,7 +37,7 @@ class ParentAwareNamingStrategyTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner(); @Test - void objectNameMatchesManagedResourceByDefault() throws MalformedObjectNameException { + void objectNameMatchesManagedResourceByDefault() { this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((context) -> { ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(new AnnotationJmxAttributeSource()); strategy.setApplicationContext(context); @@ -48,7 +47,7 @@ void objectNameMatchesManagedResourceByDefault() throws MalformedObjectNameExcep } @Test - void uniqueObjectNameAddsIdentityProperty() throws MalformedObjectNameException { + void uniqueObjectNameAddsIdentityProperty() { this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((context) -> { ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(new AnnotationJmxAttributeSource()); strategy.setApplicationContext(context); @@ -62,7 +61,7 @@ void uniqueObjectNameAddsIdentityProperty() throws MalformedObjectNameException } @Test - void sameBeanInParentContextAddsContextProperty() throws MalformedObjectNameException { + void sameBeanInParentContextAddsContextProperty() { this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((parent) -> this.contextRunner .withBean("testManagedResource", TestManagedResource.class).withParent(parent).run((context) -> { ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy( @@ -77,7 +76,7 @@ void sameBeanInParentContextAddsContextProperty() throws MalformedObjectNameExce } @Test - void uniqueObjectNameAndSameBeanInParentContextOnlyAddsIdentityProperty() throws MalformedObjectNameException { + void uniqueObjectNameAndSameBeanInParentContextOnlyAddsIdentityProperty() { this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((parent) -> this.contextRunner .withBean("testManagedResource", TestManagedResource.class).withParent(parent).run((context) -> { ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java index 58959e3c7b73..da2c65f98d91 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java @@ -468,7 +468,7 @@ static class CustomDriverConfiguration { private String name = UUID.randomUUID().toString(); @Bean - SimpleDriverDataSource dataSource() throws SQLException { + SimpleDriverDataSource dataSource() { SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass(CustomH2Driver.class); dataSource.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false", this.name)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index ea1ede9841b3..1fca027e6f85 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.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. @@ -366,7 +366,7 @@ void tomcatMinSpareThreadsMatchesProtocolDefault() throws Exception { } @Test - void tomcatMaxHttpPostSizeMatchesConnectorDefault() throws Exception { + void tomcatMaxHttpPostSizeMatchesConnectorDefault() { assertThat(this.properties.getTomcat().getMaxHttpFormPostSize().toBytes()) .isEqualTo(getDefaultConnector().getMaxPostSize()); } @@ -378,13 +378,13 @@ void tomcatBackgroundProcessorDelayMatchesEngineDefault() { } @Test - void tomcatMaxHttpFormPostSizeMatchesConnectorDefault() throws Exception { + void tomcatMaxHttpFormPostSizeMatchesConnectorDefault() { assertThat(this.properties.getTomcat().getMaxHttpFormPostSize().toBytes()) .isEqualTo(getDefaultConnector().getMaxPostSize()); } @Test - void tomcatUriEncodingMatchesConnectorDefault() throws Exception { + void tomcatUriEncodingMatchesConnectorDefault() { assertThat(this.properties.getTomcat().getUriEncoding().name()) .isEqualTo(getDefaultConnector().getURIEncoding()); } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/MavenResolverGrapeEngine.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/MavenResolverGrapeEngine.java index 575ebee0a56e..f7b9621a01d3 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/MavenResolverGrapeEngine.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/MavenResolverGrapeEngine.java @@ -35,7 +35,6 @@ import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.Exclusion; import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.DependencyRequest; import org.eclipse.aether.resolution.DependencyResult; @@ -119,7 +118,7 @@ public Object grab(Map args, Map... dependencyMaps) { classLoader.addURL(file.toURI().toURL()); } } - catch (ArtifactResolutionException | MalformedURLException ex) { + catch (MalformedURLException ex) { throw new DependencyResolutionFailedException(ex); } return null; @@ -286,7 +285,7 @@ public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) { } } - private List resolve(List dependencies) throws ArtifactResolutionException { + private List resolve(List dependencies) { try { CollectRequest collectRequest = getCollectRequest(dependencies); DependencyRequest dependencyRequest = getDependencyRequest(collectRequest); diff --git a/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java b/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java index cfac1eb58d44..24c2f9434a90 100644 --- a/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.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,7 +17,6 @@ package org.springframework.boot.devtools.tests; import java.io.File; -import java.io.IOException; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.StandardHttpRequestRetryHandler; @@ -153,7 +152,7 @@ void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) t .isEqualTo(HttpStatus.NOT_FOUND); } - static Object[] parameters() throws IOException { + static Object[] parameters() { Directories directories = new Directories(buildOutput, temp); return new Object[] { new Object[] { new LocalApplicationLauncher(directories) }, new Object[] { new ExplodedRemoteApplicationLauncher(directories) }, diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java index 12d13cc640a2..1ce4ea5bc851 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -49,7 +49,7 @@ public void afterPropertiesSet() throws Exception { startServer(); } - void startServer() throws Exception { + void startServer() { if (this.server != null) { try { if (!this.server.isStarted()) { diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java index 1ce565362b60..28fff62bc547 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.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. @@ -321,12 +321,12 @@ protected void stop() throws Exception { System.runFinalization(); } - private void cleanupCaches() throws Exception { + private void cleanupCaches() { Introspector.flushCaches(); cleanupKnownCaches(); } - private void cleanupKnownCaches() throws Exception { + private void cleanupKnownCaches() { // Whilst not strictly necessary it helps to cleanup soft reference caches // early rather than waiting for memory limits to be reached ResolvableType.clearCache(); @@ -338,13 +338,13 @@ private void cleanupKnownCaches() throws Exception { } } - private void cleanCachedIntrospectionResultsCache() throws Exception { + private void cleanCachedIntrospectionResultsCache() { clear(CachedIntrospectionResults.class, "acceptedClassLoaders"); clear(CachedIntrospectionResults.class, "strongClassCache"); clear(CachedIntrospectionResults.class, "softClassCache"); } - private void clearAnnotationUtilsCache() throws Exception { + private void clearAnnotationUtilsCache() { try { AnnotationUtils.clearCache(); } @@ -365,7 +365,7 @@ private void clear(String className, String fieldName) { } } - private void clear(Class type, String fieldName) throws Exception { + private void clear(Class type, String fieldName) { try { Field field = type.getDeclaredField(fieldName); field.setAccessible(true); diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java index dfae3b454ef1..31e2376abae6 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java @@ -33,7 +33,7 @@ class OptionalLiveReloadServerTests { @Test - void nullServer() throws Exception { + void nullServer() { OptionalLiveReloadServer server = new OptionalLiveReloadServer(null); server.startServer(); server.triggerReload(); diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java index 456b9539c2b8..cd19dd5bbd5b 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java @@ -79,7 +79,7 @@ void cantGetInstanceBeforeInitialize() { } @Test - void testRestart(CapturedOutput output) throws Exception { + void testRestart(CapturedOutput output) { Restarter.clearInstance(); Thread thread = new Thread(SampleApplication::main); thread.start(); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.java index 101250ccce17..90a1a82c2e4e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.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. @@ -37,7 +37,7 @@ class MyRestClientTests { private MockRestServiceServer server; @Test - void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails() throws Exception { + void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails() { this.server.expect(requestTo("/greet/details")).andRespond(withSuccess("hello", MediaType.TEXT_PLAIN)); String greeting = this.service.callRestService(); assertThat(greeting).isEqualTo("hello"); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java index b122f1ac087f..74205bc8a3d5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.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. @@ -34,7 +34,7 @@ class MyRepositoryTests { private UserRepository repository; @Test - void testExample() throws Exception { + void testExample() { this.entityManager.persist(new User("sboot", "1234")); User user = this.repository.findByUsername("sboot"); assertThat(user.getUsername()).isEqualTo("sboot"); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.java index 82dda7cac164..56c7adfdcbe9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.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,7 +28,7 @@ public class ExampleEndpoint { @PayloadRoot(localPart = "ExampleRequest") @ResponsePayload - public Source handleRequest() throws Exception { + public Source handleRequest() { return new StringSource("42"); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.java index ba544a77c2a6..ede8846b3798 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.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,7 +17,6 @@ package org.springframework.boot.docs.features.testing.springbootapplications.jmx; import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -38,7 +37,7 @@ class MyJmxTests { private MBeanServer mBeanServer; @Test - void exampleTest() throws MalformedObjectNameException { + void exampleTest() { assertThat(this.mBeanServer.getDomains()).contains("java.lang"); // ... } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.java index 914e4bcb0561..fba3badfb0f2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.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. @@ -36,7 +36,7 @@ class MyControllerTests { private UserVehicleService userVehicleService; @Test - void testExample() throws Exception { + void testExample() { // @formatter:off given(this.userVehicleService.getVehicleDetails("sboot")) .willReturn(new VehicleDetails("Honda", "Civic")); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.java index 04c9210217d8..b8dd93787934 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.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,7 +28,7 @@ class MyTests { private TestRestTemplate template = new TestRestTemplate(); @Test - void testRequest() throws Exception { + void testRequest() { ResponseEntity headers = this.template.getForEntity("https://myhost.example.com/example", String.class); assertThat(headers.getHeaders().getLocation()).hasHost("other.example.com"); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java index aca959aa3931..c9760a5b96dd 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -60,7 +60,7 @@ private boolean restDocsIsPresent() { private static class DocumentationHandler { - private void beforeTestMethod(TestContext testContext) throws Exception { + private void beforeTestMethod(TestContext testContext) { ManualRestDocumentation restDocumentation = findManualRestDocumentation(testContext); if (restDocumentation != null) { restDocumentation.beforeTest(testContext.getTestClass(), testContext.getTestMethod().getName()); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java index d21a88003078..93150cb23ddc 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -71,7 +71,7 @@ void prepareFailingTestInstanceShouldPrintReport(CapturedOutput output) throws E } @Test - void originalFailureIsThrownWhenReportGenerationFails() throws Exception { + void originalFailureIsThrownWhenReportGenerationFails() { TestContext testContext = mock(TestContext.class); IllegalStateException originalFailure = new IllegalStateException(); given(testContext.getTestInstance()).willThrow(originalFailure); diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java index 42e0b4256624..be4617f5b14e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java @@ -135,7 +135,7 @@ void testPropertyValuesShouldTakePrecedenceWhenInlinedPropertiesPresentAndProfil } @Test - void propertySourceOrdering() throws Exception { + void propertySourceOrdering() { TestContext context = new ExposedTestContextManager(PropertySourceOrdering.class).getExposedTestContext(); ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getApplicationContext() .getEnvironment(); diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java index d7f58040a317..1e0ded9aeb85 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -48,7 +48,7 @@ class MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests { private ExampleServiceCaller caller; @Test - void testMocking() throws Exception { + void testMocking() { given(this.exampleService.greeting()).willReturn("Boot"); assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot"); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java index a758fdb8c359..15ab29b8d2b0 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java @@ -53,7 +53,7 @@ class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { private ApplicationContext applicationContext; @Test - void testMocking() throws Exception { + void testMocking() { this.caller.sayGreeting(); then(this.service).should().greeting(); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java index 875deecc1e94..57a9ac012832 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java @@ -47,7 +47,7 @@ class SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests { private ExampleServiceCaller caller; @Test - void testSpying() throws Exception { + void testSpying() { this.caller.sayGreeting(); then(this.exampleService).should().greeting(); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java index 002ca14decd0..6d3f9893c410 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java @@ -47,7 +47,7 @@ class SpyBeanWithJdkProxyTests { private ExampleRepository repository; @Test - void jdkProxyCanBeSpied() throws Exception { + void jdkProxyCanBeSpied() { Example example = this.service.find("id"); assertThat(example.id).isEqualTo("id"); then(this.repository).should().find("id"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildpackCoordinatesTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildpackCoordinatesTests.java index ef7711aef36f..568ee4f1e575 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildpackCoordinatesTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildpackCoordinatesTests.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. @@ -49,7 +49,7 @@ void fromToml() throws IOException { } @Test - void fromTomlWhenMissingDescriptorThrowsException() throws Exception { + void fromTomlWhenMissingDescriptorThrowsException() { ByteArrayInputStream coordinates = new ByteArrayInputStream("".getBytes()); assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive)) .withMessageContaining("Buildpack descriptor 'buildpack.toml' is required") @@ -57,7 +57,7 @@ void fromTomlWhenMissingDescriptorThrowsException() throws Exception { } @Test - void fromTomlWhenMissingIDThrowsException() throws Exception { + void fromTomlWhenMissingIDThrowsException() { InputStream coordinates = createTomlStream(null, null, true, false); assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive)) .withMessageContaining("Buildpack descriptor must contain ID") @@ -65,7 +65,7 @@ void fromTomlWhenMissingIDThrowsException() throws Exception { } @Test - void fromTomlWhenMissingVersionThrowsException() throws Exception { + void fromTomlWhenMissingVersionThrowsException() { InputStream coordinates = createTomlStream("example/buildpack1", null, true, false); assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive)) .withMessageContaining("Buildpack descriptor must contain version") @@ -73,7 +73,7 @@ void fromTomlWhenMissingVersionThrowsException() throws Exception { } @Test - void fromTomlWhenMissingStacksAndOrderThrowsException() throws Exception { + void fromTomlWhenMissingStacksAndOrderThrowsException() { InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", false, false); assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive)) .withMessageContaining("Buildpack descriptor must contain either 'stacks' or 'order'") @@ -81,7 +81,7 @@ void fromTomlWhenMissingStacksAndOrderThrowsException() throws Exception { } @Test - void fromTomlWhenContainsBothStacksAndOrderThrowsException() throws Exception { + void fromTomlWhenContainsBothStacksAndOrderThrowsException() { InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", true, true); assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive)) .withMessageContaining("Buildpack descriptor must not contain both 'stacks' and 'order'") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.java index a3bcbe21b2da..cb70a7dad4c5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.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. @@ -58,7 +58,7 @@ void umaskForPath() throws IOException { @Test @DisabledOnOs(OS.WINDOWS) - void umaskForPathWithNonExistentFile() throws IOException { + void umaskForPathWithNonExistentFile() { assertThatIOException() .isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist"))); } @@ -72,7 +72,7 @@ void umaskForPathOnWindowsFails() throws IOException { } @Test - void umaskForPathWithNullPath() throws IOException { + void umaskForPathWithNullPath() { assertThatIllegalArgumentException().isThrownBy(() -> FilePermissions.umaskForPath(null)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java index 9e3abf6fe1ad..cfd08488d083 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -91,7 +91,7 @@ public ConfigurationMetadataRepository build() { return result; } - private SimpleConfigurationMetadataRepository add(InputStream in, Charset charset) throws IOException { + private SimpleConfigurationMetadataRepository add(InputStream in, Charset charset) { try { RawConfigurationMetadata metadata = this.reader.read(in, charset); return create(metadata); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index f40c04324ec4..e5cced6a177a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -112,16 +112,11 @@ protected AbstractBootArchiveTests(Class taskClass, String launcherClass, Str @BeforeEach void createTask() { - try { - File projectDir = new File(this.temp, "project"); - projectDir.mkdirs(); - this.project = GradleProjectBuilder.builder().withProjectDir(projectDir).build(); - this.project.setDescription("Test project for " + this.taskClass.getSimpleName()); - this.task = configure(this.project.getTasks().create("testArchive", this.taskClass)); - } - catch (IOException ex) { - throw new RuntimeException(ex); - } + File projectDir = new File(this.temp, "project"); + projectDir.mkdirs(); + this.project = GradleProjectBuilder.builder().withProjectDir(projectDir).build(); + this.project.setDescription("Test project for " + this.taskClass.getSimpleName()); + this.task = configure(this.project.getTasks().create("testArchive", this.taskClass)); } @Test @@ -586,7 +581,7 @@ protected File jarFile(String name) throws IOException { return file; } - private T configure(T task) throws IOException { + private T configure(T task) { AbstractArchiveTask archiveTask = task; archiveTask.getArchiveBaseName().set("test"); File destination = new File(this.temp, "destination"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java index 09c4e16757c5..25806851a443 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java @@ -92,7 +92,7 @@ abstract class AbstractPackagerTests

{ protected TestJarFile testJarFile; @BeforeEach - void setup() throws IOException { + void setup() { this.testJarFile = new TestJarFile(this.tempDir); } @@ -628,7 +628,7 @@ private Library newLibrary(File file, LibraryScope scope, boolean unpackRequired return new Library(null, file, scope, null, unpackRequired, false, included); } - protected final P createPackager() throws IOException { + protected final P createPackager() { return createPackager(this.testJarFile.getFile()); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/MainClassFinderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/MainClassFinderTests.java index d5d3c93ae827..f26dabbe2c6d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/MainClassFinderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/MainClassFinderTests.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,7 +17,6 @@ package org.springframework.boot.loader.tools; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.jar.JarFile; @@ -45,7 +44,7 @@ class MainClassFinderTests { private TestJarFile testJarFile; @BeforeEach - void setup(@TempDir File tempDir) throws IOException { + void setup(@TempDir File tempDir) { this.testJarFile = new TestJarFile(tempDir); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java index 6bf63dc842c2..2b3c73d22a9d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.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. @@ -46,7 +46,7 @@ public class TestJarFile { private final List entries = new ArrayList<>(); - public TestJarFile(File temporaryDirectory) throws IOException { + public TestJarFile(File temporaryDirectory) { this.temporaryDirectory = temporaryDirectory; this.jarSource = new File(temporaryDirectory, "jar-source"); } @@ -115,11 +115,11 @@ public File getJarSource() { return this.jarSource; } - public File getFile() throws IOException { + public File getFile() { return getFile("jar"); } - public File getFile(String extension) throws IOException { + public File getFile(String extension) { File file = new File(this.temporaryDirectory, UUID.randomUUID() + "." + extension); ZipUtil.pack(this.entries.toArray(new ZipEntrySource[0]), file); return file; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryEndRecord.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryEndRecord.java index 32c274ba17ac..b971b590abd1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryEndRecord.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryEndRecord.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. @@ -221,7 +221,7 @@ private static final class Zip64Locator { private final long offset; - private Zip64Locator(long offset, byte[] block) throws IOException { + private Zip64Locator(long offset, byte[] block) { this.offset = offset; this.zip64EndOffset = Bytes.littleEndianValue(block, ZIP64_LOCOFF, 8); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java index 9232fe6fbd8c..52ac6e40720e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.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. @@ -407,8 +407,7 @@ private String buildJarWithOutputTimestamp(MavenBuild mavenBuild) { } @TestTemplate - void whenJarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) - throws InterruptedException { + void whenJarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) { mavenBuild.project("jar-output-timestamp").execute((project) -> { File repackaged = new File(project, "target/jar-output-timestamp-0.0.1.BUILD-SNAPSHOT.jar"); List sortedLibs = Arrays.asList("BOOT-INF/lib/jakarta.servlet-api", "BOOT-INF/lib/spring-aop", diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java index 6efc9810fdb1..bb215ec09ca8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.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,8 +113,7 @@ private String buildWarWithOutputTimestamp(MavenBuild mavenBuild) { } @TestTemplate - void whenWarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) - throws InterruptedException { + void whenWarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) { mavenBuild.project("war-output-timestamp").execute((project) -> { File repackaged = new File(project, "target/war-output-timestamp-0.0.1.BUILD-SNAPSHOT.war"); List sortedLibs = Arrays.asList( diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java index 2b4c99f38bfe..160358014297 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java @@ -188,7 +188,7 @@ private void waitForSpringApplication() throws MojoFailureException, MojoExecuti } } - private void waitForForkedSpringApplication() throws IOException, MojoFailureException, MojoExecutionException { + private void waitForForkedSpringApplication() throws IOException, MojoExecutionException { try { getLog().debug("Connecting to local MBeanServer at port " + this.jmxPort); try (JMXConnector connector = execute(this.wait, this.maxAttempts, new CreateJmxConnector(this.jmxPort))) { @@ -210,7 +210,7 @@ private void waitForForkedSpringApplication() throws IOException, MojoFailureExc } private void doWaitForSpringApplication(MBeanServerConnection connection) - throws IOException, MojoExecutionException, MojoFailureException { + throws MojoExecutionException, MojoFailureException { final SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName); try { execute(this.wait, this.maxAttempts, () -> (client.isReady() ? true : null)); 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 86bef74bf444..a254a9833ccc 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 @@ -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. @@ -111,14 +111,14 @@ private boolean isForked() { return true; } - private void stopForkedProcess() throws IOException, MojoFailureException, MojoExecutionException { + private void stopForkedProcess() throws IOException, MojoExecutionException { try (JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort)) { MBeanServerConnection connection = connector.getMBeanServerConnection(); doStop(connection); } } - private void stop() throws IOException, MojoFailureException, MojoExecutionException { + private void stop() throws IOException, MojoExecutionException { doStop(ManagementFactory.getPlatformMBeanServer()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedContext.java index 3ed36e2d59b8..b57637ff4b12 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedContext.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. @@ -25,7 +25,6 @@ import javax.servlet.ServletException; import org.apache.catalina.Container; -import org.apache.catalina.LifecycleException; import org.apache.catalina.Manager; import org.apache.catalina.Wrapper; import org.apache.catalina.core.StandardContext; @@ -60,7 +59,7 @@ public void setManager(Manager manager) { super.setManager(manager); } - void deferredLoadOnStartup() throws LifecycleException { + void deferredLoadOnStartup() { doWithThreadContextClassLoader(getLoader().getClassLoader(), () -> getLoadOnStartupWrappers(findChildren()).forEach(this::load)); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java index 2671b13e1ec3..42b8eac0024f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java @@ -100,7 +100,7 @@ void runWhenContextIsBeingClosedInAnotherThreadWaitsUntilContextIsInactive() thr } @Test - void runDueToExitDuringRefreshWhenContextHasBeenClosedDoesNotDeadlock() throws InterruptedException { + void runDueToExitDuringRefreshWhenContextHasBeenClosedDoesNotDeadlock() { GenericApplicationContext context = new GenericApplicationContext(); TestSpringApplicationShutdownHook shutdownHook = new TestSpringApplicationShutdownHook(); shutdownHook.registerApplicationContext(context); 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 8c757ec386b1..addb9efc5792 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 @@ -723,12 +723,12 @@ void hashCodeIsStored() { } @Test - void hasIndexedElementWhenHasIndexedElementReturnsTrue() throws Exception { + void hasIndexedElementWhenHasIndexedElementReturnsTrue() { assertThat(ConfigurationPropertyName.of("foo[bar]").hasIndexedElement()).isTrue(); } @Test - void hasIndexedElementWhenHasNoIndexedElementReturnsFalse() throws Exception { + void hasIndexedElementWhenHasNoIndexedElementReturnsFalse() { assertThat(ConfigurationPropertyName.of("foo.bar").hasIndexedElement()).isFalse(); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationToStringConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationToStringConverterTests.java index 19dd01effbe9..a24400bf6b90 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationToStringConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationToStringConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -55,7 +55,7 @@ void convertWithFormatAndUnitShouldUseFormatAndUnit(ConversionService conversion assertThat(converted).isEqualTo("1s"); } - static Stream conversionServices() throws Exception { + static Stream conversionServices() { return ConversionServiceArguments.with(new DurationToStringConverter()); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/PeriodToStringConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/PeriodToStringConverterTests.java index 96d37d0a9699..6470c84f151e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/PeriodToStringConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/PeriodToStringConverterTests.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. @@ -78,7 +78,7 @@ void convertWithWeekUnitShouldConvertToStringInDays(ConversionService conversion assertThat(converted).isEqualTo("371d"); } - static Stream conversionServices() throws Exception { + static Stream conversionServices() { return ConversionServiceArguments.with(new PeriodToStringConverter()); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java index 3324acb57118..5be9489dbad5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.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. @@ -131,13 +131,13 @@ void cycleWithAnUnknownStartIsNotAnalyzed() { } @Test - void cycleWithCircularReferencesAllowed() throws IOException { + void cycleWithCircularReferencesAllowed() { FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class, true); assertThat(analysis.getAction()).contains("Despite circular references being allowed"); } @Test - void cycleWithCircularReferencesProhibited() throws IOException { + void cycleWithCircularReferencesProhibited() { FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class, false); assertThat(analysis.getAction()).contains("As a last resort"); } 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 468209c8cd0f..0fb4f517d884 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 @@ -19,7 +19,6 @@ import java.io.File; import java.io.IOException; import java.net.SocketException; -import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -513,7 +512,7 @@ void referenceClearingIsDisabled() { } @Test - void nonExistentUploadDirectoryIsCreatedUponMultipartUpload() throws IOException, URISyntaxException { + void nonExistentUploadDirectoryIsCreatedUponMultipartUpload() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0); AtomicReference servletContextReference = new AtomicReference<>(); factory.addInitializers((servletContext) -> { 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 ad0b5f098d23..893ea0dfc24b 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 @@ -17,7 +17,6 @@ package org.springframework.boot.web.reactive.server; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.ServerSocket; @@ -27,10 +26,8 @@ import java.util.Arrays; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -455,7 +452,7 @@ void whenARequestIsActiveAfterGracefulShutdownEndsThenStopWillComplete() throws } @Test - void whenARequestIsActiveThenStopWillComplete() throws InterruptedException, BrokenBarrierException { + void whenARequestIsActiveThenStopWillComplete() throws InterruptedException { AbstractReactiveWebServerFactory factory = getFactory(); BlockingHandler blockingHandler = new BlockingHandler(); this.webServer = factory.getWebServer(blockingHandler); @@ -501,8 +498,7 @@ protected void whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed() throws Excep } @Test - protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() - throws InterruptedException, ExecutionException, IOException { + protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() { AbstractReactiveWebServerFactory factory = getFactory(); Http2 http2 = new Http2(); http2.setEnabled(true); 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 37b3ea74c45b..e1c39b5ad6e2 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 @@ -47,9 +47,7 @@ import java.util.Objects; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.RunnableFuture; @@ -1161,7 +1159,7 @@ void whenAnAsyncRequestRemainsInFlightThenShutDownGracefullyDoesNotInvokeCallbac } @Test - void whenARequestIsActiveThenStopWillComplete() throws InterruptedException, BrokenBarrierException { + void whenARequestIsActiveThenStopWillComplete() throws InterruptedException { AbstractServletWebServerFactory factory = getFactory(); BlockingServlet blockingServlet = new BlockingServlet(); this.webServer = factory @@ -1201,8 +1199,7 @@ protected void whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed() throws Excep } @Test - protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() - throws InterruptedException, ExecutionException, IOException, URISyntaxException { + protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() throws IOException, URISyntaxException { AbstractServletWebServerFactory factory = getFactory(); Http2 http2 = new Http2(); http2.setEnabled(true); @@ -1213,8 +1210,7 @@ protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() } @Test - void whenARequestIsActiveAfterGracefulShutdownEndsThenStopWillComplete() - throws InterruptedException, BrokenBarrierException { + void whenARequestIsActiveAfterGracefulShutdownEndsThenStopWillComplete() throws InterruptedException { AbstractServletWebServerFactory factory = getFactory(); factory.setShutdown(Shutdown.GRACEFUL); BlockingServlet blockingServlet = new BlockingServlet(); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/ChatService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/ChatService.java index 2dbb3229cd7d..4a522045936b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/ChatService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/ChatService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -47,7 +47,7 @@ public void onDisconnect(AtmosphereResourceEvent event) { @org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class, decoders = JacksonEncoderDecoder.class) - public Message onMessage(Message message) throws IOException { + public Message onMessage(Message message) { this.logger.info("Author " + message.getAuthor() + " sent message " + message.getMessage()); return message; } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/SampleAtmosphereApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/SampleAtmosphereApplication.java index cdb3d7435bb9..d4fbdee23294 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/SampleAtmosphereApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/src/main/java/smoketest/atmosphere/SampleAtmosphereApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -61,7 +61,7 @@ public ServletRegistrationBean atmosphereServlet() { return registration; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) { SpringApplication.run(SampleAtmosphereApplication.class, args); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/src/main/java/smoketest/batch/SampleBatchApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/src/main/java/smoketest/batch/SampleBatchApplication.java index cba6e41a2b14..9e6507cd4629 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/src/main/java/smoketest/batch/SampleBatchApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/src/main/java/smoketest/batch/SampleBatchApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -53,12 +53,12 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext context) } @Bean - public Job job() throws Exception { + public Job job() { return this.jobs.get("job").start(step1()).build(); } @Bean - protected Step step1() throws Exception { + protected Step step1() { return this.steps.get("step1").tasklet(tasklet()).build(); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/main/java/smoketest/parent/SampleParentContextApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/main/java/smoketest/parent/SampleParentContextApplication.java index a7157b793ec3..34af61a72eeb 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/main/java/smoketest/parent/SampleParentContextApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/main/java/smoketest/parent/SampleParentContextApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -34,7 +34,7 @@ @SpringBootApplication public class SampleParentContextApplication { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { new SpringApplicationBuilder(Parent.class).child(SampleParentContextApplication.class).run(args); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/consumer/SampleIntegrationParentApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/consumer/SampleIntegrationParentApplicationTests.java index 4fde078b5920..b918d093b10a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/consumer/SampleIntegrationParentApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/consumer/SampleIntegrationParentApplicationTests.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. @@ -46,7 +46,7 @@ class SampleIntegrationParentApplicationTests { @Test - void testVanillaExchange(@TempDir Path temp) throws Exception { + void testVanillaExchange(@TempDir Path temp) { File inputDir = new File(temp.toFile(), "input"); File outputDir = new File(temp.toFile(), "output"); try (ConfigurableApplicationContext app = SpringApplication.run(SampleParentContextApplication.class, diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java index 880413cd52bc..f898c6f2fdb5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.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. @@ -41,13 +41,13 @@ void endpointShouldReturnUnauthorized() { } @Test - void preflightRequestToEndpointShouldReturnOk() throws Exception { + void preflightRequestToEndpointShouldReturnOk() { this.webClient.options().uri("/actuator/env").header("Origin", "http://localhost:8080") .header("Access-Control-Request-Method", "GET").exchange().expectStatus().isOk(); } @Test - void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden() throws Exception { + void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden() { this.webClient.options().uri("/actuator/env").header("Origin", "http://localhost:9095") .header("Access-Control-Request-Method", "GET").exchange().expectStatus().isForbidden(); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.java index 5488198ccb98..2f77338b652b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.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. @@ -54,7 +54,7 @@ protected static class AuthenticationSecurity { @SuppressWarnings("deprecation") @Bean - public InMemoryUserDetailsManager inMemoryUserDetailsManager() throws Exception { + public InMemoryUserDetailsManager inMemoryUserDetailsManager() { return new InMemoryUserDetailsManager( User.withDefaultPasswordEncoder().username("admin").password("admin") .roles("ADMIN", "USER", "ACTUATOR").build(), diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/src/main/java/smoketest/webservices/endpoint/HolidayEndpoint.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/src/main/java/smoketest/webservices/endpoint/HolidayEndpoint.java index bd6b86257786..a00f4d0f78db 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/src/main/java/smoketest/webservices/endpoint/HolidayEndpoint.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/src/main/java/smoketest/webservices/endpoint/HolidayEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -19,11 +19,7 @@ import java.text.SimpleDateFormat; import java.util.Date; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactoryConfigurationException; - import org.jdom2.Element; -import org.jdom2.JDOMException; import org.jdom2.Namespace; import org.jdom2.filter.Filters; import org.jdom2.xpath.XPathExpression; @@ -47,8 +43,7 @@ public class HolidayEndpoint { private HumanResourceService humanResourceService; - public HolidayEndpoint(HumanResourceService humanResourceService) - throws JDOMException, XPathFactoryConfigurationException, XPathExpressionException { + public HolidayEndpoint(HumanResourceService humanResourceService) { this.humanResourceService = humanResourceService; Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); XPathFactory xPathFactory = XPathFactory.instance(); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java index fac7fda44007..2a8924fcbd44 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java @@ -80,7 +80,7 @@ public static void tick() throws Exception { broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); } - public static void broadcast(String message) throws Exception { + public static void broadcast(String message) { Collection snakes = new CopyOnWriteArrayList<>(SnakeTimer.getSnakes()); for (Snake snake : snakes) { try { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty10/src/main/java/smoketest/websocket/jetty10/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty10/src/main/java/smoketest/websocket/jetty10/snake/SnakeTimer.java index c140a4703b8e..fba04c5671f9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty10/src/main/java/smoketest/websocket/jetty10/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty10/src/main/java/smoketest/websocket/jetty10/snake/SnakeTimer.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. @@ -80,7 +80,7 @@ public static void tick() throws Exception { broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); } - public static void broadcast(String message) throws Exception { + public static void broadcast(String message) { Collection snakes = new CopyOnWriteArrayList<>(SnakeTimer.getSnakes()); for (Snake snake : snakes) { try { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java index 869d8b241423..82be974569e3 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java @@ -80,7 +80,7 @@ public static void tick() throws Exception { broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); } - public static void broadcast(String message) throws Exception { + public static void broadcast(String message) { Collection snakes = new CopyOnWriteArrayList<>(SnakeTimer.getSnakes()); for (Snake snake : snakes) { try { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java index c30b276ed10c..1b044c018bee 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java @@ -80,7 +80,7 @@ public static void tick() throws Exception { broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); } - public static void broadcast(String message) throws Exception { + public static void broadcast(String message) { Collection snakes = new CopyOnWriteArrayList<>(SnakeTimer.getSnakes()); for (Snake snake : snakes) { try { From 3d203d0215081dd4ce48466457cd264a801c5960 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 26 May 2022 16:26:09 +0100 Subject: [PATCH 011/161] Polish --- .../boot/build/DeployedPlugin.java | 1 + .../boot/build/ExtractResources.java | 1 + .../boot/build/bom/bomr/UpgradeBom.java | 3 +- .../expose/IncludeExcludeEndpointFilter.java | 4 -- .../web/servlet/CompositeHandlerAdapter.java | 3 +- .../MvcWebEndpointIntegrationTests.java | 41 ++++++++++--------- .../ClientResourcesBuilderCustomizer.java | 9 ++-- .../RestClientBuilderCustomizer.java | 7 ++-- .../DownloadConfigBuilderCustomizer.java | 12 +++--- .../ConnectionFactoryOptionsInitializer.java | 8 ++-- .../kafka/KafkaAutoConfigurationTests.java | 1 + ...2ResourceServerAutoConfigurationTests.java | 8 ++-- ...2ResourceServerAutoConfigurationTests.java | 8 ++-- ...ml2RelyingPartyAutoConfigurationTests.java | 10 +++-- ...activeMultipartAutoConfigurationTests.java | 7 +--- .../servlet/WebMvcAutoConfigurationTests.java | 3 +- .../applicationcontext/MyDemoBean.java | 1 + .../AbstractMockBeanOnGenericTests.java | 5 ++- .../platform/io/InspectedContent.java | 5 ++- .../boot/loader/tools/Repackager.java | 4 +- .../validation/ValidationBindHandler.java | 5 +-- .../boot/context/config/ConfigDataTests.java | 3 +- .../ConfigurationPropertiesTests.java | 1 - .../log4j2/Log4J2LoggingSystemTests.java | 1 + .../boot/image/paketo/PaketoBuilderTests.java | 40 ++++++++---------- .../SampleHazelcast4ApplicationTests.java | 5 +-- ...ampleSessionHazelcastApplicationTests.java | 8 ++-- .../SampleSessionJdbcApplicationTests.java | 8 ++-- .../SampleSessionMongoApplicationTests.java | 8 ++-- .../SampleSessionRedisApplicationTests.java | 8 ++-- .../src/main/webapp/WEB-INF/web.xml | 6 --- 31 files changed, 116 insertions(+), 118 deletions(-) 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/mongo/embedded/DownloadConfigBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/DownloadConfigBuilderCustomizer.java index 1689d0bbab38..bb2fb2e83e3a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/DownloadConfigBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/DownloadConfigBuilderCustomizer.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. @@ -18,11 +18,12 @@ import de.flapdoodle.embed.process.config.store.DownloadConfig; import de.flapdoodle.embed.process.config.store.ImmutableDownloadConfig; +import de.flapdoodle.embed.process.config.store.ImmutableDownloadConfig.Builder; /** * Callback interface that can be implemented by beans wishing to customize the - * {@link DownloadConfig} via an {@link ImmutableDownloadConfig.Builder} whilst retaining - * default auto-configuration. + * {@link DownloadConfig} via a {@link Builder} whilst retaining default + * auto-configuration. * * @author Michael Gmeiner * @since 2.2.0 @@ -31,9 +32,8 @@ public interface DownloadConfigBuilderCustomizer { /** - * Customize the {@link ImmutableDownloadConfig.Builder}. - * @param downloadConfigBuilder the {@link ImmutableDownloadConfig.Builder} to - * customize + * Customize the {@link Builder}. + * @param downloadConfigBuilder the {@link Builder} to customize */ void customize(ImmutableDownloadConfig.Builder downloadConfigBuilder); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryOptionsInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryOptionsInitializer.java index f5e10f4c7342..6a17dfde1c29 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryOptionsInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryOptionsInitializer.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,15 +28,15 @@ import org.springframework.util.StringUtils; /** - * Initialize a {@link ConnectionFactoryOptions.Builder} based on {@link R2dbcProperties}. + * Initialize a {@link Builder} based on {@link R2dbcProperties}. * * @author Stephane Nicoll */ class ConnectionFactoryOptionsInitializer { /** - * Initialize a {@link io.r2dbc.spi.ConnectionFactoryOptions.Builder - * ConnectionFactoryOptions.Builder} using the specified properties. + * Initialize a {@link 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/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 405fe04c36ee..24b78b2849b5 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 @@ -432,6 +432,7 @@ void listenerProperties() { @Test @Deprecated + @SuppressWarnings("deprecation") void logOnlyRecordMetadataProperty() { this.contextRunner.withPropertyValues("spring.kafka.listener.only-log-record-metadata=true").run((context) -> { 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 fb4f3880cf68..4f9edf6cb838 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 @@ -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. @@ -148,7 +148,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); @@ -171,7 +171,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); @@ -194,7 +194,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); 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 e0a2beb50322..2f90444def0d 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 @@ -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. @@ -144,7 +144,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); @@ -166,7 +166,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); @@ -189,7 +189,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); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java index da95d6308259..1eb9498c92ca 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.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. @@ -257,9 +257,11 @@ private boolean hasFilter(AssertableWebApplicationContext context, Class { + @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/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/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 1900405f17aa..44e330ebd246 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 @@ -80,7 +80,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); @@ -106,8 +107,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 { @@ -122,14 +124,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 { @@ -145,7 +149,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().buildpacks().contains( @@ -173,7 +178,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().buildpacks().contains( @@ -204,7 +210,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); @@ -231,7 +238,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().buildpacks().contains( @@ -352,20 +360,6 @@ private File projectArchiveFile() { return new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0]; } - private String javaMajorVersion() { - String javaVersion = System.getProperty("java.version"); - if (javaVersion.startsWith("1.")) { - return javaVersion.substring(2, 3); - } - else { - int firstDotIndex = javaVersion.indexOf("."); - if (firstDotIndex != -1) { - return javaVersion.substring(0, firstDotIndex); - } - } - return javaVersion; - } - private boolean startsWithOneOf(String actual, List expectedPrefixes) { for (String prefix : expectedPrefixes) { if (actual.startsWith(prefix)) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast4ApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast4ApplicationTests.java index 551207721245..9f1817c54527 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast4ApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast3/src/test/java/smoketest/hazelcast3/SampleHazelcast4ApplicationTests.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. @@ -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 @@ / - - - - - From 3f91ed037f398f8d8b393b0ae0f8768062b3fa51 Mon Sep 17 00:00:00 2001 From: Damiano Albani Date: Wed, 25 May 2022 23:28:41 +0200 Subject: [PATCH 012/161] Fix Custom Layers Configuration section title in Maven plugin docs See gh-31172 --- .../spring-boot-maven-plugin/src/docs/asciidoc/packaging.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging.adoc index e497482f08cb..081df4913159 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging.adoc @@ -71,7 +71,7 @@ include::../maven/packaging/disable-layers-pom.xml[tags=disable-layers] -[[packaging.layers.configuration=]] +[[packaging.layers.configuration]] === Custom Layers Configuration Depending on your application, you may want to tune how layers are created and add new ones. This can be done using a separate configuration file that should be registered as shown below: From ebf276c00528b273db90719b56a655b61eaf3e3d Mon Sep 17 00:00:00 2001 From: Guirong Hu Date: Fri, 6 May 2022 12:30:02 +0800 Subject: [PATCH 013/161] Assert that sources does not contain null elements See gh-30878 --- .../boot/context/properties/bind/Binder.java | 5 +++-- .../boot/context/properties/bind/BinderTests.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index b0e67042bdf0..31983009e543 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.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. @@ -72,7 +72,7 @@ public class Binder { * @param sources the sources used for binding */ public Binder(ConfigurationPropertySource... sources) { - this(Arrays.asList(sources), null, null, null); + this((sources != null) ? Arrays.asList(sources) : null, null, null, null); } /** @@ -182,6 +182,7 @@ public Binder(Iterable sources, PlaceholdersResolve List conversionServices, Consumer propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) { Assert.notNull(sources, "Sources must not be null"); + sources.forEach((source) -> Assert.notNull(source, "Sources cannot contain null values")); this.sources = sources; this.placeholdersResolver = (placeholdersResolver != null) ? placeholdersResolver : PlaceholdersResolver.NONE; this.bindConverter = BindConverter.get(conversionServices, propertyEditorInitializer); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java index a1cf88f87ac3..360e567ad68a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java @@ -71,10 +71,20 @@ class BinderTests { @Test void createWhenSourcesIsNullShouldThrowException() { + assertThatIllegalArgumentException().isThrownBy(() -> new Binder((ConfigurationPropertySource[]) null)) + .withMessageContaining("Sources must not be null"); assertThatIllegalArgumentException().isThrownBy(() -> new Binder((Iterable) null)) .withMessageContaining("Sources must not be null"); } + @Test + void createWhenSourcesContainNullValuesShouldThrowException() { + assertThatIllegalArgumentException().isThrownBy(() -> new Binder(new ConfigurationPropertySource[] { null })) + .withMessageContaining("Sources cannot contain null values"); + assertThatIllegalArgumentException().isThrownBy(() -> new Binder(Collections.singletonList(null))) + .withMessageContaining("Sources cannot contain null values"); + } + @Test void bindWhenNameIsNullShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> this.binder.bind((ConfigurationPropertyName) null, From 56c3a5f0abf28e5359ab722a1a5846d5aa8e4705 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 27 May 2022 10:01:06 +0100 Subject: [PATCH 014/161] Polish "Assert that sources does not contain null elements" See gh-30878 --- .../boot/context/properties/bind/Binder.java | 4 +++- .../context/properties/bind/BinderTests.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index 31983009e543..0b47cff04e5b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -182,7 +182,9 @@ public Binder(Iterable sources, PlaceholdersResolve List conversionServices, Consumer propertyEditorInitializer, BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) { Assert.notNull(sources, "Sources must not be null"); - sources.forEach((source) -> Assert.notNull(source, "Sources cannot contain null values")); + for (ConfigurationPropertySource source : sources) { + Assert.notNull(source, "Sources must not contain null elements"); + } this.sources = sources; this.placeholdersResolver = (placeholdersResolver != null) ? placeholdersResolver : PlaceholdersResolver.NONE; this.bindConverter = BindConverter.get(conversionServices, propertyEditorInitializer); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java index 360e567ad68a..388348bf9a47 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java @@ -70,19 +70,27 @@ class BinderTests { private Binder binder = new Binder(this.sources); @Test - void createWhenSourcesIsNullShouldThrowException() { + void createWhenSourcesIsNullArrayShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> new Binder((ConfigurationPropertySource[]) null)) .withMessageContaining("Sources must not be null"); + } + + @Test + void creatWhenSourcesIsNullIterableShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> new Binder((Iterable) null)) .withMessageContaining("Sources must not be null"); } @Test - void createWhenSourcesContainNullValuesShouldThrowException() { + void createWhenArraySourcesContainsNullElementShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> new Binder(new ConfigurationPropertySource[] { null })) - .withMessageContaining("Sources cannot contain null values"); + .withMessageContaining("Sources must not contain null elements"); + } + + @Test + void createWhenIterableSourcesContainsNullElementShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> new Binder(Collections.singletonList(null))) - .withMessageContaining("Sources cannot contain null values"); + .withMessageContaining("Sources must not contain null elements"); } @Test From d38bc13fd5578065cca00e84279d194555e13c9e Mon Sep 17 00:00:00 2001 From: Youri Bonnaffe Date: Mon, 23 May 2022 07:52:45 +0200 Subject: [PATCH 015/161] Remove mimepull dependency Mimepull dependency was introduced in 1c18fd8 for gh-14924 to force the version as the one coming from saaj-impl was not on Maven Central. This is no longer the case. Version 1.10.0 of Mimepull has been built with Java 11, breaking compatibility with Java 8 for Spring Boot. See gh-31145 --- spring-boot-project/spring-boot-dependencies/build.gradle | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 47ef46422270..e7ce54a9bb5a 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1293,13 +1293,6 @@ bom { ] } } - library("MIMEPull", "1.10.0") { - group("org.jvnet.mimepull") { - modules = [ - "mimepull" - ] - } - } library("Mockito", "4.5.1") { group("org.mockito") { imports = [ From 83e8c039b3e579d973e64fc094a25ad8be428ced Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 27 May 2022 11:14:04 +0100 Subject: [PATCH 016/161] Add application/wasm to MIME mappings Closes gh-30885 --- .../java/org/springframework/boot/web/server/MimeMappings.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index 3928bcc2bb70..eda975577a00 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -203,6 +203,7 @@ public final class MimeMappings implements Iterable { mappings.add("xul", "application/vnd.mozilla.xul+xml"); mappings.add("xwd", "image/x-xwindowdump"); mappings.add("vsd", "application/vnd.visio"); + mappings.add("wasm", "application/wasm"); mappings.add("wav", "audio/x-wav"); mappings.add("wbmp", "image/vnd.wap.wbmp"); mappings.add("wml", "text/vnd.wap.wml"); From 682ac53f32ba4f1bcadaf84f26635f6788a10166 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 27 May 2022 15:58:00 +0100 Subject: [PATCH 017/161] Ensure that config processor runs with only AutoConfiguration Fixes gh-31186 --- .../ConfigurationMetadataAnnotationProcessor.java | 7 +++++-- .../ConfigurationMetadataAnnotationProcessorTests.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 7cc52dfac797..0423e723bd86 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.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. @@ -59,7 +59,8 @@ * @author Jonas Keßler * @since 1.2.0 */ -@SupportedAnnotationTypes({ ConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_ANNOTATION, +@SupportedAnnotationTypes({ ConfigurationMetadataAnnotationProcessor.AUTO_CONFIGURATION_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_ANNOTATION, ConfigurationMetadataAnnotationProcessor.CONTROLLER_ENDPOINT_ANNOTATION, ConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION, ConfigurationMetadataAnnotationProcessor.JMX_ENDPOINT_ANNOTATION, @@ -97,6 +98,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor static final String NAME_ANNOTATION = "org.springframework.boot.context.properties.bind.Name"; + static final String AUTO_CONFIGURATION_ANNOTATION = "org.springframework.boot.autoconfigure.AutoConfiguration"; + private static final Set SUPPORTED_OPTIONS = Collections .unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java index 6114aea6ba4a..e9825a236883 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java @@ -80,7 +80,8 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene @Test void supportedAnnotations() { assertThat(new ConfigurationMetadataAnnotationProcessor().getSupportedAnnotationTypes()) - .containsExactlyInAnyOrder("org.springframework.boot.context.properties.ConfigurationProperties", + .containsExactlyInAnyOrder("org.springframework.boot.autoconfigure.AutoConfiguration", + "org.springframework.boot.context.properties.ConfigurationProperties", "org.springframework.context.annotation.Configuration", "org.springframework.boot.actuate.endpoint.annotation.Endpoint", "org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpoint", From eb8b9e17c5c2354588ce47b58ad9024b7c679d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matei=20Cern=C4=83ianu?= Date: Mon, 30 May 2022 14:19:54 +0300 Subject: [PATCH 018/161] Fix "spring.factories" typos in database initialization documentation See gh-31203 --- .../src/docs/asciidoc/howto/data-initialization.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc index 30b83f1189f9..172550e7358d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc @@ -200,7 +200,7 @@ Spring Boot will automatically detect beans of the following types that initiali - `SpringLiquibase` If you are using a third-party starter for a database initialization library, it may provide a detector such that beans of other types are also detected automatically. -To have other beans be detected, register an implementation of `DatabaseInitializerDetector` in `META-INF/spring-factories`. +To have other beans be detected, register an implementation of `DatabaseInitializerDetector` in `META-INF/spring.factories`. @@ -215,5 +215,5 @@ Spring Boot will automatically detect beans of the following types that depends - `NamedParameterJdbcOperations` If you are using a third-party starter data access library, it may provide a detector such that beans of other types are also detected automatically. -To have other beans be detected, register an implementation of `DependsOnDatabaseInitializationDetector` in `META-INF/spring-factories`. +To have other beans be detected, register an implementation of `DependsOnDatabaseInitializationDetector` in `META-INF/spring.factories`. Alternatively, annotate the bean's class or its `@Bean` method with `@DependsOnDatabaseInitialization`. From 3a0ab010669d2bd574de1c566aa3ebb75688e69a Mon Sep 17 00:00:00 2001 From: heqiang <531364804@qq.com> Date: Sun, 29 May 2022 18:00:18 +0800 Subject: [PATCH 019/161] Polish "Remove boxing" See gh-31197 --- .../boot/autoconfigure/condition/OnExpressionCondition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java index a7098f325a9d..c7a79e5c011d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java @@ -51,7 +51,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM return ConditionOutcome.noMatch(messageBuilder.because("no BeanFactory available.")); } - private Boolean evaluateExpression(ConfigurableListableBeanFactory beanFactory, String expression) { + private boolean evaluateExpression(ConfigurableListableBeanFactory beanFactory, String expression) { BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver(); if (resolver == null) { resolver = new StandardBeanExpressionResolver(); From ad1214c97253aa139c98ac9efecbcc75587b1f0e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 30 May 2022 15:13:12 +0200 Subject: [PATCH 020/161] Upgrade copyright year of changed files See gh-31197 --- .../boot/autoconfigure/condition/OnExpressionCondition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java index c7a79e5c011d..703eca8244a2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. From 419ac26e0d2494da6c9d5ca597452deed8ccde0a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 30 May 2022 17:15:45 +0100 Subject: [PATCH 021/161] Use conventions for source and encoding of aggregatedJavadoc Closes gh-31210 --- spring-boot-project/spring-boot-docs/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index bfa7996eb4be..aedda22a2b0d 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -193,10 +193,8 @@ task aggregatedJavadoc(type: Javadoc) { options { author = true docTitle = "Spring Boot ${project.version} API" - encoding = "UTF-8" memberLevel = "protected" outputLevel = "quiet" - source = "1.8" splitIndex = true stylesheetFile = file("src/main/javadoc/spring-javadoc.css") use = true From da8dafe1381272c3c7d657b250a40e7b74c966c7 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 30 May 2022 18:01:55 +0100 Subject: [PATCH 022/161] Make afterResolve hook used by bootJar and bootWar more robust Previously, ResolvedDependencies used hasError on ResolvedConfiguration to check that it was safe to work with all of the resolved configuration's artifacts and their files. This check is not sufficient as errors can still occur later on. This commit updates ResolvedDependencies to use a lenient configuration, thereby avoiding any problems that may be caused by errors that occur after the hasError check. Closes gh-30586 --- .../boot/gradle/tasks/bundling/ResolvedDependencies.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ResolvedDependencies.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ResolvedDependencies.java index fc7bdb89dba7..b4644094b00d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ResolvedDependencies.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ResolvedDependencies.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. @@ -24,6 +24,7 @@ import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.LenientConfiguration; import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.artifacts.ResolvedConfiguration; @@ -75,7 +76,11 @@ private static class ResolvedConfigurationDependencies { ResolvedConfigurationDependencies(Set projectDependencyIds, ResolvedConfiguration resolvedConfiguration) { if (!resolvedConfiguration.hasError()) { - for (ResolvedArtifact resolvedArtifact : resolvedConfiguration.getResolvedArtifacts()) { + LenientConfiguration lenientConfiguration = resolvedConfiguration.getLenientConfiguration(); + // Ensure that all files are resolved, allowing Gradle to resolve in + // parallel if they are not + lenientConfiguration.getFiles(); + for (ResolvedArtifact resolvedArtifact : lenientConfiguration.getArtifacts()) { ModuleVersionIdentifier id = resolvedArtifact.getModuleVersion().getId(); boolean projectDependency = projectDependencyIds .contains(id.getGroup() + ":" + id.getName() + ":" + id.getVersion()); From 0b6c147a8751a71aed2fcc7af8a8ec2c2d1c7ca6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 30 May 2022 19:22:30 +0100 Subject: [PATCH 023/161] Polish --- .../boot/gradle/tasks/bundling/AbstractBootArchiveTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index e5cced6a177a..442135eb95b4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -49,6 +49,7 @@ import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.DependencySet; +import org.gradle.api.artifacts.LenientConfiguration; import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.artifacts.ResolvableDependencies; @@ -663,7 +664,9 @@ void addContent() throws IOException { artifacts.add(mockProjectArtifact("second-project-library-SNAPSHOT.jar", "com.example", "second-project-library", "1.0.0.SNAPSHOT")); ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class); - given(resolvedConfiguration.getResolvedArtifacts()).willReturn(artifacts); + LenientConfiguration lenientConfiguration = mock(LenientConfiguration.class); + given(resolvedConfiguration.getLenientConfiguration()).willReturn(lenientConfiguration); + given(lenientConfiguration.getArtifacts()).willReturn(artifacts); Configuration configuration = mock(Configuration.class); given(configuration.getResolvedConfiguration()).willReturn(resolvedConfiguration); ResolvableDependencies resolvableDependencies = mock(ResolvableDependencies.class); From 348662b15ec3e79fb76a908b8ca2b8e86aada11a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 31 May 2022 10:57:22 +0100 Subject: [PATCH 024/161] Remove unused deduceFromApplicationContext and supporting code Closes gh-31218 --- .../boot/WebApplicationType.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/WebApplicationType.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/WebApplicationType.java index ad13427c91fc..ebfd6692b698 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/WebApplicationType.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/WebApplicationType.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -54,10 +54,6 @@ public enum WebApplicationType { private static final String JERSEY_INDICATOR_CLASS = "org.glassfish.jersey.servlet.ServletContainer"; - private static final String SERVLET_APPLICATION_CONTEXT_CLASS = "org.springframework.web.context.WebApplicationContext"; - - private static final String REACTIVE_APPLICATION_CONTEXT_CLASS = "org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext"; - static WebApplicationType deduceFromClasspath() { if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null) && !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null) && !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) { @@ -71,23 +67,4 @@ static WebApplicationType deduceFromClasspath() { return WebApplicationType.SERVLET; } - static WebApplicationType deduceFromApplicationContext(Class applicationContextClass) { - if (isAssignable(SERVLET_APPLICATION_CONTEXT_CLASS, applicationContextClass)) { - return WebApplicationType.SERVLET; - } - if (isAssignable(REACTIVE_APPLICATION_CONTEXT_CLASS, applicationContextClass)) { - return WebApplicationType.REACTIVE; - } - return WebApplicationType.NONE; - } - - private static boolean isAssignable(String target, Class type) { - try { - return ClassUtils.resolveClassName(target, null).isAssignableFrom(type); - } - catch (Throwable ex) { - return false; - } - } - } From c379456722b77a37aff9228dabc5f0a78d4f2821 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 6 Jun 2022 17:01:28 +0100 Subject: [PATCH 025/161] Remove dependency management for spring-ldap-ldif-batch The spring-ldap-ldif-batch module was removed in Spring LDAP 2.4.0 in favor of the equivalent code that already exists in Spring Batch. This commit aligns Boot's dependency management with this removal. Closes gh-31254 --- spring-boot-project/spring-boot-dependencies/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index e7ce54a9bb5a..59fb738c2040 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1744,7 +1744,6 @@ bom { modules = [ "spring-ldap-core", "spring-ldap-core-tiger", - "spring-ldap-ldif-batch", "spring-ldap-ldif-core", "spring-ldap-odm", "spring-ldap-test" From bbb5966bca94fb51712713a1faa5ef691b6477f4 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 7 Jun 2022 09:06:32 +0200 Subject: [PATCH 026/161] Upgrade integration tests to Apache Maven 3.8.5 Closes gh-31260 --- .../spring-boot-tools/spring-boot-maven-plugin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle index f220f448ebd9..3e081437288b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle @@ -143,7 +143,7 @@ task xsdResources(type: Sync) { } prepareMavenBinaries { - versions "3.8.1", "3.6.3", "3.5.4" + versions "3.8.5", "3.6.3", "3.5.4" } artifacts { From 95e0d6c0f7acfe1c612478e8a1d5e71660dab397 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Tue, 7 Jun 2022 14:37:12 +0200 Subject: [PATCH 027/161] Update smoke tests to avoid conflicts with NAME environment variable This commit updates several smoke tests in order to avoid conflicts with NAME environment variable that is present in WSL and causes project build to fail. Previous attempt to fix this in 7da42d71 was incomplete. See gh-31267 --- .../main/java/smoketest/aop/service/HelloWorldService.java | 4 ++-- .../src/main/resources/application.properties | 2 +- .../test/java/smoketest/aop/SampleAopApplicationTests.java | 4 ++-- .../java/smoketest/jetty/service/HelloWorldService.java | 4 ++-- .../spring-boot-smoke-test-profile/application.yml | 2 +- .../java/smoketest/profile/SampleProfileApplication.java | 2 +- .../main/java/smoketest/profile/service/GenericService.java | 6 +++--- .../java/smoketest/profile/service/GoodbyeWorldService.java | 4 ++-- .../java/smoketest/profile/service/HelloWorldService.java | 4 ++-- .../src/main/resources/application.yml | 4 ++-- .../smoketest/profile/SampleProfileApplicationTests.java | 2 +- .../main/java/smoketest/simple/SampleSimpleApplication.java | 4 ++-- .../java/smoketest/simple/service/HelloWorldService.java | 6 +++--- .../src/main/resources/application.properties | 2 +- .../java/smoketest/simple/SampleSimpleApplicationTests.java | 4 ++-- .../java/smoketest/testng/service/HelloWorldService.java | 4 ++-- .../java/smoketest/tomcat/service/HelloWorldService.java | 4 ++-- .../main/java/smoketest/xml/service/HelloWorldService.java | 4 ++-- 18 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java index b061ebca2f1e..b3e05a05e085 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties index b04cdc39b58a..f8f9c0ac7978 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties @@ -1 +1 @@ -name: Phil +test.name: Phil diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java index 3d216259a860..5cf677c5741c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.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. @@ -60,7 +60,7 @@ void testDefaultSettings(CapturedOutput output) { @Test void testCommandLineOverrides(CapturedOutput output) { - SampleAopApplication.main(new String[] { "--name=Gordon" }); + SampleAopApplication.main(new String[] { "--test.name=Gordon" }); assertThat(output).contains("Hello Gordon"); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java index d74455b18fd7..d2564ad58b93 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml index 8689513d3b1c..f524f375bda5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml @@ -1 +1 @@ -hello: Bonjour +test.hello: Bonjour diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java index c64eb7e7a988..2df5781f41b6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java @@ -30,7 +30,7 @@ public class SampleProfileApplication implements CommandLineRunner { // Simple example shows how a command line spring application can execute an // injected bean service. Also demonstrates how you can use @Value to inject - // command line args ('--name=whatever') or application properties + // command line args ('--test.name=whatever') or application properties @Autowired private MessageService helloWorldService; diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java index f4a8d358da73..f83df4a51b49 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -24,10 +24,10 @@ @Profile({ "generic" }) public class GenericService implements MessageService { - @Value("${hello:Hello}") + @Value("${test.hello:Hello}") private String hello; - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java index a18cc59594ff..6ef189d2c1d9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -24,7 +24,7 @@ @Profile("goodbye") public class GoodbyeWorldService implements MessageService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java index 33aa6b3c187e..a343ea61ae68 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -24,7 +24,7 @@ @Profile({ "hello", "default" }) public class HelloWorldService implements MessageService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml index ed01e5c852c6..b6ffc61aa82d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml @@ -1,6 +1,6 @@ -name: Phil +test.name: Phil --- spring.config.activate.on-profile: goodbye | dev -name: Everyone +test.name: Everyone diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java index d4dd213b0c3d..af3515361884 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java @@ -65,7 +65,7 @@ void testGenericProfile(CapturedOutput output) { * This is a profile that requires a new environment property, and one which is * only overridden in the current working directory. That file also only contains * partial overrides, and the default application.yml should still supply the - * "name" property. + * "test.name" property. */ System.setProperty("spring.profiles.active", "generic"); SampleProfileApplication.main(); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java index 2f9f0cb27565..27b19d59ac86 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.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. @@ -30,7 +30,7 @@ public class SampleSimpleApplication implements CommandLineRunner { // Simple example shows how a command line spring application can execute an // injected bean service. Also demonstrates how you can use @Value to inject - // command line args ('--name=whatever') or application properties + // command line args ('--test.name=whatever') or application properties @Autowired private HelloWorldService helloWorldService; diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java index f89c1f556475..1540265e4f7c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -24,10 +24,10 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; - @Value("${duration:10s}") + @Value("${test.duration:10s}") private Duration duration; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties index 080603f9e549..43dac287187b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties @@ -1,4 +1,4 @@ -name=Phil +test.name=Phil sample.name=Andy spring.banner.image.bitdepth=8 diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java index 8cdf90067db0..ad085d13337a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -60,7 +60,7 @@ void testDefaultSettings(CapturedOutput output) { @Test void testCommandLineOverrides(CapturedOutput output) { - SampleSimpleApplication.main(new String[] { "--name=Gordon", "--duration=1m" }); + SampleSimpleApplication.main(new String[] { "--test.name=Gordon", "--test.duration=1m" }); assertThat(output).contains("Hello Gordon for 60 seconds"); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java index 5749cc1792b3..79d96f92517b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java index b49003bdec03..ba74eb7dad2a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java index 675d864a4886..57ab83873b8f 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { From 0834dc5b01a9a2c29599cd550587e6780e3518c5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 8 Jun 2022 12:08:40 +0100 Subject: [PATCH 028/161] Polish "Update smoke tests to avoid conflicts with NAME environment variable" See gh-31267 --- .../java/smoketest/jetty10/service/HelloWorldService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java index 732de935ba6e..ffd94c184c34 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.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. @@ -22,7 +22,7 @@ @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; public String getHelloMessage() { From a651061e2cd230364c16a043b8ccfc0bfd8da114 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 8 Jun 2022 19:23:26 +0100 Subject: [PATCH 029/161] Remove SpringApplicationHierarchyTests Closes gh-31281 --- .../SpringApplicationHierarchyTests.java | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java deleted file mode 100644 index 5de0389b3143..000000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2012-2020 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; -import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration; -import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration; -import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; -import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration; -import org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration; -import org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; -import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.test.util.ApplicationContextTestUtils; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Configuration; - -/** - * Test for application hierarchies created using {@link SpringApplicationBuilder}. - * - * @author Dave Syer - */ -class SpringApplicationHierarchyTests { - - private ConfigurableApplicationContext context; - - @AfterEach - void after() { - ApplicationContextTestUtils.closeAll(this.context); - } - - @Test - void testParent() { - SpringApplicationBuilder builder = new SpringApplicationBuilder(Child.class); - builder.parent(Parent.class); - this.context = builder.run("--server.port=0", "--management.metrics.use-global-registry=false"); - } - - @Test - void testChild() { - SpringApplicationBuilder builder = new SpringApplicationBuilder(Parent.class); - builder.child(Child.class); - this.context = builder.run("--server.port=0", "--management.metrics.use-global-registry=false"); - } - - @Configuration - @EnableAutoConfiguration(exclude = { ElasticsearchDataAutoConfiguration.class, - ElasticsearchRepositoriesAutoConfiguration.class, CassandraAutoConfiguration.class, - CassandraDataAutoConfiguration.class, MongoDataAutoConfiguration.class, - MongoReactiveDataAutoConfiguration.class, Neo4jAutoConfiguration.class, Neo4jDataAutoConfiguration.class, - Neo4jRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, - RedisRepositoriesAutoConfiguration.class, FlywayAutoConfiguration.class, MetricsAutoConfiguration.class }) - static class Parent { - - } - - @Configuration - @EnableAutoConfiguration(exclude = { ElasticsearchDataAutoConfiguration.class, - ElasticsearchRepositoriesAutoConfiguration.class, CassandraAutoConfiguration.class, - CassandraDataAutoConfiguration.class, MongoDataAutoConfiguration.class, - MongoReactiveDataAutoConfiguration.class, Neo4jAutoConfiguration.class, Neo4jDataAutoConfiguration.class, - Neo4jRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, - RedisRepositoriesAutoConfiguration.class, FlywayAutoConfiguration.class, MetricsAutoConfiguration.class }) - static class Child { - - } - -} From ea85dccd613dea6de5fe995bfa2965254469eff6 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:57:30 +0200 Subject: [PATCH 030/161] Upgrade Ubuntu version in CI images Closes gh-31287 --- ci/images/ci-image-jdk11/Dockerfile | 2 +- ci/images/ci-image-jdk17/Dockerfile | 2 +- ci/images/ci-image-jdk18/Dockerfile | 2 +- ci/images/ci-image/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/images/ci-image-jdk11/Dockerfile b/ci/images/ci-image-jdk11/Dockerfile index 2107cfce18ab..10e279c64e80 100644 --- a/ci/images/ci-image-jdk11/Dockerfile +++ b/ci/images/ci-image-jdk11/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image-jdk17/Dockerfile b/ci/images/ci-image-jdk17/Dockerfile index 289066d61eba..678891b1eff2 100644 --- a/ci/images/ci-image-jdk17/Dockerfile +++ b/ci/images/ci-image-jdk17/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image-jdk18/Dockerfile b/ci/images/ci-image-jdk18/Dockerfile index f76acac35f0d..c84b6b3de48d 100644 --- a/ci/images/ci-image-jdk18/Dockerfile +++ b/ci/images/ci-image-jdk18/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image/Dockerfile b/ci/images/ci-image/Dockerfile index 52b60e363b4b..2c64e0d3c818 100644 --- a/ci/images/ci-image/Dockerfile +++ b/ci/images/ci-image/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh From 976f1ac355d7c6c102c9568999955d78932bce17 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:54:57 +0200 Subject: [PATCH 031/161] Upgrade Java 8 version in CI image Closes gh-31291 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index d0148a8a3438..43d362a3d772 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -3,7 +3,7 @@ set -e case "$1" in java8) - echo "https://github.com/bell-sw/Liberica/releases/download/8u332+9/bellsoft-jdk8u332+9-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/8u333+2/bellsoft-jdk8u333+2-linux-amd64.tar.gz" ;; java11) echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15+10/bellsoft-jdk11.0.15+10-linux-amd64.tar.gz" From 4822c9b809873da4d26dc78e2c4a88521d9f9851 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:55:32 +0200 Subject: [PATCH 032/161] Upgrade Java 11 version in CI image Closes gh-31293 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 43d362a3d772..faa9f7f4cade 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -6,7 +6,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/8u333+2/bellsoft-jdk8u333+2-linux-amd64.tar.gz" ;; java11) - echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15+10/bellsoft-jdk11.0.15+10-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15.1+2/bellsoft-jdk11.0.15.1+2-linux-amd64.tar.gz" ;; java17) echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64.tar.gz" From c07623e04096a655ca41cda2252525171f0c1a52 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:56:06 +0200 Subject: [PATCH 033/161] Upgrade Java 17 version in CI image Closes gh-31290 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index faa9f7f4cade..8d433651c80c 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -9,7 +9,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15.1+2/bellsoft-jdk11.0.15.1+2-linux-amd64.tar.gz" ;; java17) - echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz" ;; java18) echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64.tar.gz" From f96f21c8a23ea96566b07a99407a20874aa07bc0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:56:42 +0200 Subject: [PATCH 034/161] Upgrade Java 18 version in CI image Closes gh-31294 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 8d433651c80c..7c9601f124b9 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -12,7 +12,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz" ;; java18) - echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1.1+2/bellsoft-jdk18.0.1.1+2-linux-amd64.tar.gz" ;; *) echo $"Unknown java version" From b02826366381c60ea2d8830fbfdfc3f85e2096ad Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:58:12 +0200 Subject: [PATCH 035/161] Upgrade CI to Docker 20.10.17 Closes gh-31297 --- ci/images/get-docker-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-docker-url.sh b/ci/images/get-docker-url.sh index 73dbcf0463e0..96cd00531312 100755 --- a/ci/images/get-docker-url.sh +++ b/ci/images/get-docker-url.sh @@ -1,5 +1,5 @@ #!/bin/bash set -e -version="20.10.16" +version="20.10.17" echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz"; From 1a8c1217ed8f0fa02c94bbc84f624d4522665290 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:59:27 +0200 Subject: [PATCH 036/161] Upgrade Ubuntu version in CI images Closes gh-31288 --- ci/images/ci-image-jdk11/Dockerfile | 2 +- ci/images/ci-image-jdk17/Dockerfile | 2 +- ci/images/ci-image-jdk18/Dockerfile | 2 +- ci/images/ci-image/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/images/ci-image-jdk11/Dockerfile b/ci/images/ci-image-jdk11/Dockerfile index 2107cfce18ab..10e279c64e80 100644 --- a/ci/images/ci-image-jdk11/Dockerfile +++ b/ci/images/ci-image-jdk11/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image-jdk17/Dockerfile b/ci/images/ci-image-jdk17/Dockerfile index 289066d61eba..678891b1eff2 100644 --- a/ci/images/ci-image-jdk17/Dockerfile +++ b/ci/images/ci-image-jdk17/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image-jdk18/Dockerfile b/ci/images/ci-image-jdk18/Dockerfile index f76acac35f0d..c84b6b3de48d 100644 --- a/ci/images/ci-image-jdk18/Dockerfile +++ b/ci/images/ci-image-jdk18/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh diff --git a/ci/images/ci-image/Dockerfile b/ci/images/ci-image/Dockerfile index 52b60e363b4b..2c64e0d3c818 100644 --- a/ci/images/ci-image/Dockerfile +++ b/ci/images/ci-image/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20220426 +FROM ubuntu:focal-20220531 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh From 87840c755b6c47a41a8e26fd0ddd84c091007b21 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 07:59:58 +0200 Subject: [PATCH 037/161] Upgrade Java 8 version in CI image Closes gh-31286 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index d0148a8a3438..43d362a3d772 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -3,7 +3,7 @@ set -e case "$1" in java8) - echo "https://github.com/bell-sw/Liberica/releases/download/8u332+9/bellsoft-jdk8u332+9-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/8u333+2/bellsoft-jdk8u333+2-linux-amd64.tar.gz" ;; java11) echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15+10/bellsoft-jdk11.0.15+10-linux-amd64.tar.gz" From 1c85e1083af42a86287486f8d876df17f819c5ec Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 08:00:26 +0200 Subject: [PATCH 038/161] Upgrade Java 11 version in CI image Closes gh-31285 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 43d362a3d772..faa9f7f4cade 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -6,7 +6,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/8u333+2/bellsoft-jdk8u333+2-linux-amd64.tar.gz" ;; java11) - echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15+10/bellsoft-jdk11.0.15+10-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15.1+2/bellsoft-jdk11.0.15.1+2-linux-amd64.tar.gz" ;; java17) echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64.tar.gz" From a93255553991bad937576e4a89ceb2010ca9d816 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 08:00:55 +0200 Subject: [PATCH 039/161] Upgrade Java 17 version in CI image Closes gh-31284 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index faa9f7f4cade..8d433651c80c 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -9,7 +9,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15.1+2/bellsoft-jdk11.0.15.1+2-linux-amd64.tar.gz" ;; java17) - echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz" ;; java18) echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64.tar.gz" From d39f4efb052f9bc720b38aa72e0ee4eedb4e80e4 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 08:01:32 +0200 Subject: [PATCH 040/161] Upgrade Java 18 version in CI image Closes gh-31292 --- ci/images/get-jdk-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 8d433651c80c..7c9601f124b9 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -12,7 +12,7 @@ case "$1" in echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz" ;; java18) - echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64.tar.gz" + echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1.1+2/bellsoft-jdk18.0.1.1+2-linux-amd64.tar.gz" ;; *) echo $"Unknown java version" From 152766c07a207f346b1b3b47d535eec63188a066 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jun 2022 08:02:07 +0200 Subject: [PATCH 041/161] Upgrade CI to Docker 20.10.17 Closes gh-31289 --- ci/images/get-docker-url.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/get-docker-url.sh b/ci/images/get-docker-url.sh index 73dbcf0463e0..96cd00531312 100755 --- a/ci/images/get-docker-url.sh +++ b/ci/images/get-docker-url.sh @@ -1,5 +1,5 @@ #!/bin/bash set -e -version="20.10.16" +version="20.10.17" echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz"; From ed897fc92277be9e424d170775cb79bff34ef169 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Jun 2022 19:37:50 +0100 Subject: [PATCH 042/161] Start building against Spring Framework 5.3.21 snapshots See gh-31318 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index b815378bde72..4c63fa978aaf 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1701,7 +1701,7 @@ bom { ] } } - library("Spring Framework", "5.3.20") { + library("Spring Framework", "5.3.21-SNAPSHOT") { group("org.springframework") { imports = [ "spring-framework-bom" From 29cd148e052925f457790f5be020d767fc8ccc87 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Jun 2022 20:55:14 +0100 Subject: [PATCH 043/161] Start building against Spring Framework 5.3.1 snapshots See gh-31319 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 59fb738c2040..80c5e5f9e6ae 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1687,7 +1687,7 @@ bom { ] } } - library("Spring Framework", "5.3.20") { + library("Spring Framework", "5.3.21-SNAPSHOT") { prohibit("[6.0.0-M1,)") { because "we upgrade in Spring Boot 3.x" } From e02803d341b2be03718a15339f66eda729ce0277 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 10 Jun 2022 11:32:57 +0100 Subject: [PATCH 044/161] Configure max HTTP header size when using HTTP2 with Tomcat Closes gh-31322 --- .../embedded/TomcatWebServerFactoryCustomizer.java | 5 +++++ .../TomcatWebServerFactoryCustomizerTests.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java index e53729ab1c86..deb41dff1476 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java @@ -280,6 +280,11 @@ private void customizeMaxHttpHeaderSize(ConfigurableTomcatWebServerFactory facto if (handler instanceof AbstractHttp11Protocol) { AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler; protocol.setMaxHttpHeaderSize(maxHttpHeaderSize); + for (UpgradeProtocol upgradeProtocol : protocol.findUpgradeProtocols()) { + if (upgradeProtocol instanceof Http2Protocol) { + ((Http2Protocol) upgradeProtocol).setMaxHeaderSize(maxHttpHeaderSize); + } + } } }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java index 48af84f5e557..a12d66738b07 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java @@ -182,6 +182,19 @@ void customMaxHttpHeaderSize() { .getMaxHttpHeaderSize()).isEqualTo(DataSize.ofKilobytes(1).toBytes())); } + @Test + void customMaxHttpHeaderSizeWithHttp2() { + bind("server.max-http-header-size=1KB", "server.http2.enabled=true"); + customizeAndRunServer((server) -> { + AbstractHttp11Protocol protocolHandler = (AbstractHttp11Protocol) server.getTomcat().getConnector() + .getProtocolHandler(); + long expectedSize = DataSize.ofKilobytes(1).toBytes(); + assertThat(protocolHandler.getMaxHttpHeaderSize()).isEqualTo(expectedSize); + assertThat(((Http2Protocol) protocolHandler.getUpgradeProtocol("h2c")).getMaxHeaderSize()) + .isEqualTo(expectedSize); + }); + } + @Test void customMaxHttpHeaderSizeIgnoredIfNegative() { bind("server.max-http-header-size=-1"); From 6df9f506428bda02e412480efa8e590e22d4267b Mon Sep 17 00:00:00 2001 From: Georg Pirklbauer Date: Thu, 7 Apr 2022 12:39:37 +0200 Subject: [PATCH 045/161] Update Dynatrace documentation for Micrometer 1.9.0 Update the actuator documentation for Dynatrace to reflect the updates and improvements that were made in Micrometer 1.9.0. See gh-31132 --- .../src/docs/asciidoc/actuator/metrics.adoc | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc index ea5fe8a5bc29..2188911ae731 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc @@ -166,24 +166,37 @@ You can also change the interval at which metrics are sent to Datadog: [[actuator.metrics.export.dynatrace]] ==== Dynatrace + Dynatrace offers two metrics ingest APIs, both of which are implemented for {micrometer-registry-docs}/dynatrace[Micrometer]. +You can find the Dynatrace documentation on Micrometer metrics ingest {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/micrometer[here]. Configuration properties in the `v1` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API]. Configuration properties in the `v2` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API]. -Note that this integration can export only to either the `v1` or `v2` version of the API at a time. +Note that this integration can export only to either the `v1` or `v2` version of the API at a time, with `v2` being the preferred one. If the `device-id` (required for v1 but not used in v2) is set in the `v1` namespace, metrics are exported to the `v1` endpoint. Otherwise, `v2` is assumed. - - [[actuator.metrics.export.dynatrace.v2-api]] ===== v2 API + You can use the v2 API in two ways. -If a local OneAgent is running on the host, metrics are automatically exported to the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/local-api/[local OneAgent ingest endpoint]. +[[actuator.metrics.export.dynatrace.v2-api.auto-config]] +====== Auto-configuration + +Dynatrace auto-configuration is available for hosts that are monitored by the OneAgent or by the Dynatrace Operator for Kubernetes. + +**Local OneAgent:** If a OneAgent is running on the host, metrics are automatically exported to the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/local-api/[local OneAgent ingest endpoint]. The ingest endpoint forwards the metrics to the Dynatrace backend. + +**Dynatrace Kubernetes Operator:** When running in Kubernetes with the Dynatrace Operator installed, the registry will automatically pick up your endpoint URI and API token from the operator instead. +Dynatrace Operator-based auto-configuration is available from Micrometer version `1.9.0`, which is distributed with Spring Boot since version `2.7.0`. + This is the default behavior and requires no special setup beyond a dependency on `io.micrometer:micrometer-registry-dynatrace`. -If no local OneAgent is running, the endpoint of the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API] and an API token are required. +[[actuator.metrics.export.dynatrace.v2-api.manual-config]] +====== Manual configuration + +If no auto-configuration is available, the endpoint of the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API] and an API token are required. The {dynatrace-help}/dynatrace-api/basics/dynatrace-api-authentication/[API token] must have the "`Ingest metrics`" (`metrics.ingest`) permission set. We recommend limiting the scope of the token to this one permission. You must ensure that the endpoint URI contains the path (for example, `/api/v2/metrics/ingest`): @@ -205,15 +218,16 @@ The example below configures metrics export using the `example` environment id: api-token: "YOUR_TOKEN" ---- -When using the Dynatrace v2 API, the following optional features are available: +When using the Dynatrace v2 API, the following optional features are available (more details can be found in the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/micrometer#dt-configuration-properties[Dynatrace documentation]): * Metric key prefix: Sets a prefix that is prepended to all exported metric keys. * Enrich with Dynatrace metadata: If a OneAgent or Dynatrace operator is running, enrich metrics with additional metadata (for example, about the host, process, or pod). * Default dimensions: Specify key-value pairs that are added to all exported metrics. - If tags with the same key are specified with Micrometer, they overwrite the default dimensions. +If tags with the same key are specified with Micrometer, they overwrite the default dimensions. +* Use Dynatrace Summary instruments: In some cases the Micrometer Dynatrace registry created metrics that were rejected. In Micrometer 1.9.x, this was fixed by introducing Dynatrace-specific summary instruments. Setting this toggle to false forces Micrometer to fall back to the behavior that was the default before 1.9.x. It should only be used when encountering problems while migrating from 1.8.x to 1.9.x. It is possible to not specify a URI and API token, as shown in the following example. -In this scenario, the local OneAgent endpoint is used: +In this scenario, the automatically configured endpoint is used: [source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- @@ -228,12 +242,12 @@ In this scenario, the local OneAgent endpoint is used: default-dimensions: key1: "value1" key2: "value2" + use-dynatrace-summary-instruments: true # (default: true) ---- - - [[actuator.metrics.export.dynatrace.v1-api]] ===== v1 API (Legacy) + The Dynatrace v1 API metrics registry pushes metrics to the configured URI periodically by using the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API]. For backwards-compatibility with existing setups, when `device-id` is set (required for v1, but not used in v2), metrics are exported to the Timeseries v1 endpoint. To export metrics to {micrometer-registry-docs}/dynatrace[Dynatrace], your API token, device ID, and URI must be provided: @@ -256,6 +270,7 @@ For the v1 API, you must specify the base environment URI without a path, as the [[actuator.metrics.export.dynatrace.version-independent-settings]] ===== Version-independent Settings + In addition to the API endpoint and token, you can also change the interval at which metrics are sent to Dynatrace. The default export interval is `60s`. The following example sets the export interval to 30 seconds: @@ -269,7 +284,7 @@ The following example sets the export interval to 30 seconds: step: "30s" ---- -You can find more information on how to set up the Dynatrace exporter for Micrometer in {micrometer-registry-docs}/dynatrace[the Micrometer documentation]. +You can find more information on how to set up the Dynatrace exporter for Micrometer in the {micrometer-registry-docs}/dynatrace[Micrometer documentation] and the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/micrometer[Dynatrace documentation]. From 0f7fa84214ef8ec81a2a338eeb762b4743e7212c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 10 Jun 2022 12:33:19 -0700 Subject: [PATCH 046/161] Polish 'Update Dynatrace documentation for Micrometer 1.9.0' See gh-31132 --- .../src/docs/asciidoc/actuator/metrics.adoc | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc index 2188911ae731..18dce5c43f8d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc @@ -166,36 +166,37 @@ You can also change the interval at which metrics are sent to Datadog: [[actuator.metrics.export.dynatrace]] ==== Dynatrace - Dynatrace offers two metrics ingest APIs, both of which are implemented for {micrometer-registry-docs}/dynatrace[Micrometer]. You can find the Dynatrace documentation on Micrometer metrics ingest {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/micrometer[here]. Configuration properties in the `v1` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API]. Configuration properties in the `v2` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API]. -Note that this integration can export only to either the `v1` or `v2` version of the API at a time, with `v2` being the preferred one. +Note that this integration can export only to either the `v1` or `v2` version of the API at a time, with `v2` being preferred. If the `device-id` (required for v1 but not used in v2) is set in the `v1` namespace, metrics are exported to the `v1` endpoint. Otherwise, `v2` is assumed. + + [[actuator.metrics.export.dynatrace.v2-api]] ===== v2 API - You can use the v2 API in two ways. + + [[actuator.metrics.export.dynatrace.v2-api.auto-config]] ====== Auto-configuration - Dynatrace auto-configuration is available for hosts that are monitored by the OneAgent or by the Dynatrace Operator for Kubernetes. **Local OneAgent:** If a OneAgent is running on the host, metrics are automatically exported to the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/local-api/[local OneAgent ingest endpoint]. The ingest endpoint forwards the metrics to the Dynatrace backend. **Dynatrace Kubernetes Operator:** When running in Kubernetes with the Dynatrace Operator installed, the registry will automatically pick up your endpoint URI and API token from the operator instead. -Dynatrace Operator-based auto-configuration is available from Micrometer version `1.9.0`, which is distributed with Spring Boot since version `2.7.0`. This is the default behavior and requires no special setup beyond a dependency on `io.micrometer:micrometer-registry-dynatrace`. + + [[actuator.metrics.export.dynatrace.v2-api.manual-config]] ====== Manual configuration - If no auto-configuration is available, the endpoint of the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API] and an API token are required. The {dynatrace-help}/dynatrace-api/basics/dynatrace-api-authentication/[API token] must have the "`Ingest metrics`" (`metrics.ingest`) permission set. We recommend limiting the scope of the token to this one permission. @@ -224,7 +225,10 @@ When using the Dynatrace v2 API, the following optional features are available ( * Enrich with Dynatrace metadata: If a OneAgent or Dynatrace operator is running, enrich metrics with additional metadata (for example, about the host, process, or pod). * Default dimensions: Specify key-value pairs that are added to all exported metrics. If tags with the same key are specified with Micrometer, they overwrite the default dimensions. -* Use Dynatrace Summary instruments: In some cases the Micrometer Dynatrace registry created metrics that were rejected. In Micrometer 1.9.x, this was fixed by introducing Dynatrace-specific summary instruments. Setting this toggle to false forces Micrometer to fall back to the behavior that was the default before 1.9.x. It should only be used when encountering problems while migrating from 1.8.x to 1.9.x. +* Use Dynatrace Summary instruments: In some cases the Micrometer Dynatrace registry created metrics that were rejected. +In Micrometer 1.9.x, this was fixed by introducing Dynatrace-specific summary instruments. +Setting this toggle to `false` forces Micrometer to fall back to the behavior that was the default before 1.9.x. +It should only be used when encountering problems while migrating from Micrometer 1.8.x to 1.9.x. It is possible to not specify a URI and API token, as shown in the following example. In this scenario, the automatically configured endpoint is used: @@ -245,9 +249,10 @@ In this scenario, the automatically configured endpoint is used: use-dynatrace-summary-instruments: true # (default: true) ---- + + [[actuator.metrics.export.dynatrace.v1-api]] ===== v1 API (Legacy) - The Dynatrace v1 API metrics registry pushes metrics to the configured URI periodically by using the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API]. For backwards-compatibility with existing setups, when `device-id` is set (required for v1, but not used in v2), metrics are exported to the Timeseries v1 endpoint. To export metrics to {micrometer-registry-docs}/dynatrace[Dynatrace], your API token, device ID, and URI must be provided: @@ -270,7 +275,6 @@ For the v1 API, you must specify the base environment URI without a path, as the [[actuator.metrics.export.dynatrace.version-independent-settings]] ===== Version-independent Settings - In addition to the API endpoint and token, you can also change the interval at which metrics are sent to Dynatrace. The default export interval is `60s`. The following example sets the export interval to 30 seconds: From ed1e7382ab46b673362d7e6e747af20012ef7273 Mon Sep 17 00:00:00 2001 From: Anthony Vanelverdinghe Date: Wed, 8 Jun 2022 15:27:54 +0200 Subject: [PATCH 047/161] Fix typo in ImportCandidates javadoc See gh-31277 --- .../boot/context/annotation/ImportCandidates.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java index 3db5cc44a78b..db7141de8237 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java @@ -61,7 +61,7 @@ public Iterator iterator() { * Loads the names of import candidates from the classpath. * * The names of the import candidates are stored in files named - * {@code META-INF/spring/full-qualified-annotation-name.import} on the classpath. + * {@code META-INF/spring/full-qualified-annotation-name.imports} on the classpath. * Every line contains the full qualified name of the candidate class. Comments are * supported using the # character. * @param annotation annotation to load From 31b0264d94c2f5690ca18e8d2be3a8e4f75d0d15 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 10 Jun 2022 14:18:49 -0700 Subject: [PATCH 048/161] Ensure conversion service actually converts to the correct type Update `BindConverter` with a guard to ensure that the resulting object is the correct type. Fixes gh-28592 --- .../properties/bind/BindConverter.java | 7 ++- .../ConfigurationPropertiesTests.java | 46 +++++++++++++++++++ .../WithPublicObjectToObjectMethod.java | 43 +++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java index a38335401f48..0e477296d9be 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.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. @@ -106,7 +106,10 @@ private Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor for (ConversionService delegate : this.delegates) { try { if (delegate.canConvert(sourceType, targetType)) { - return delegate.convert(source, sourceType, targetType); + Object converted = delegate.convert(source, sourceType, targetType); + if (targetType.getType().isInstance(converted)) { + return converted; + } } } catch (ConversionException ex) { 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 79cd1b677726..eda312947acf 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 @@ -57,6 +57,7 @@ import org.springframework.boot.context.properties.bind.DefaultValue; import org.springframework.boot.context.properties.bind.validation.BindValidationException; import org.springframework.boot.context.properties.source.ConfigurationPropertyName; +import org.springframework.boot.convert.ApplicationConversionService; import org.springframework.boot.convert.DataSizeUnit; import org.springframework.boot.convert.DurationFormat; import org.springframework.boot.convert.DurationStyle; @@ -1081,6 +1082,15 @@ void boundPropertiesShouldBeRecorded() { assertThat(keys.stream().map(ConfigurationPropertyName::toString)).contains("name", "nested.name"); } + @Test // gh-28592 + void loadWhenBindingWithCustomConverterAndObjectToObjectMethod() { + this.context.getBeanFactory().setConversionService(ApplicationConversionService.getSharedInstance()); + load(WithCustomConverterAndObjectToObjectMethodConfiguration.class, "test.item=foo"); + WithCustomConverterAndObjectToObjectMethodProperties bean = this.context + .getBean(WithCustomConverterAndObjectToObjectMethodProperties.class); + assertThat(bean.getItem().getValue()).isEqualTo("foo"); + } + private AnnotationConfigApplicationContext load(Class configuration, String... inlinedProperties) { return load(new Class[] { configuration }, inlinedProperties); } @@ -2710,4 +2720,40 @@ static class WithPublicStringConstructorPropertiesConfiguration { } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(WithCustomConverterAndObjectToObjectMethodProperties.class) + static class WithCustomConverterAndObjectToObjectMethodConfiguration { + + @Bean + @ConfigurationPropertiesBinding + WithObjectToObjectMethodConverter withObjectToObjectMethodConverter() { + return new WithObjectToObjectMethodConverter(); + } + + } + + @ConfigurationProperties("test") + static class WithCustomConverterAndObjectToObjectMethodProperties { + + private WithPublicObjectToObjectMethod item; + + WithPublicObjectToObjectMethod getItem() { + return this.item; + } + + void setItem(WithPublicObjectToObjectMethod item) { + this.item = item; + } + + } + + static class WithObjectToObjectMethodConverter implements Converter { + + @Override + public WithPublicObjectToObjectMethod convert(String source) { + return new WithPublicObjectToObjectMethod(source); + } + + } + } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java new file mode 100644 index 000000000000..f3a5b167c342 --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java @@ -0,0 +1,43 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.context.properties; + +import java.util.Optional; + +/** + * Data object with a pubic method picked up by the {@code ObjectToObjectConverter}. Used + * in {@link ConfigurationPropertiesTests}. + * + * @author Phillip Webb + */ +public class WithPublicObjectToObjectMethod { + + private final String value; + + WithPublicObjectToObjectMethod(String value) { + this.value = value; + } + + String getValue() { + return this.value; + } + + public static Optional from(String value) { + return Optional.of(new WithPublicObjectToObjectMethod(value)); + } + +} \ No newline at end of file From 63fdd729f58a1591864ddb867a947f503f0c58e7 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 10 Jun 2022 16:12:38 -0700 Subject: [PATCH 049/161] Refine conversion service type check Update fix to account for primitive types. See gh-28592 --- .../boot/context/properties/bind/BindConverter.java | 3 ++- .../context/properties/WithPublicObjectToObjectMethod.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java index 0e477296d9be..430270b89cf6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java @@ -42,6 +42,7 @@ import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.ConditionalGenericConverter; import org.springframework.core.convert.support.GenericConversionService; +import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; /** @@ -107,7 +108,7 @@ private Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor try { if (delegate.canConvert(sourceType, targetType)) { Object converted = delegate.convert(source, sourceType, targetType); - if (targetType.getType().isInstance(converted)) { + if (ClassUtils.isAssignableValue(targetType.getType(), converted)) { return converted; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java index f3a5b167c342..06fed654591f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/WithPublicObjectToObjectMethod.java @@ -40,4 +40,4 @@ public static Optional from(String value) { return Optional.of(new WithPublicObjectToObjectMethod(value)); } -} \ No newline at end of file +} From d3b4cbada8fc687a4f73514f70f5f03043a3fc94 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:43:34 +0200 Subject: [PATCH 050/161] Set LATEST_GA to false in CI pipeline Closes gh-31120 --- ci/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 436358c993a1..56a5fc4b773f 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -755,7 +755,7 @@ jobs: <<: *sdkman-task-params RELEASE_TYPE: RELEASE BRANCH: ((branch)) - LATEST_GA: true + LATEST_GA: false - name: update-homebrew-tap serial: true plan: @@ -771,7 +771,7 @@ jobs: image: ci-image file: git-repo/ci/tasks/update-homebrew-tap.yml params: - LATEST_GA: true + LATEST_GA: false - put: homebrew-tap-repo params: repository: updated-homebrew-tap-repo From 9fdd471adfe763cb74857542bdf07c3321a49537 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Sat, 21 May 2022 14:51:30 +0200 Subject: [PATCH 051/161] Use Lambda-based API in Spring Security examples See gh-31143 --- .../src/docs/asciidoc/data/sql.adoc | 2 +- .../exposeall/MySecurityConfiguration.java | 6 +++--- .../typical/MySecurityConfiguration.java | 10 ++++++---- .../DevProfileSecurityConfiguration.java | 20 ++++++++++++------- .../client/MyOAuthClientConfiguration.java | 6 +++--- .../MyWebFluxSecurityConfiguration.java | 12 ++++++----- .../enablehttps/MySecurityConfig.java | 4 ++-- .../testing/slicetests/MyConfiguration.java | 2 +- .../slicetests/MySecurityConfiguration.java | 2 +- 9 files changed, 37 insertions(+), 27 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc index a449894d13e6..69619c935023 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc @@ -351,7 +351,7 @@ In simple setups, a `SecurityFilterChain` like the following can be used: [source,java,indent=0,subs="verbatim"] ---- -include::{docs-java}/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java[] +include::{docs-java}/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java[tag=!customizer] ---- WARNING: The H2 console is only intended for use during development. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.java index ba372dd74c6d..39ebcb33021e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.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. @@ -27,8 +27,8 @@ public class MySecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.requestMatcher(EndpointRequest.toAnyEndpoint()) - .authorizeRequests((requests) -> requests.anyRequest().permitAll()); + http.requestMatcher(EndpointRequest.toAnyEndpoint()); + http.authorizeRequests((requests) -> requests.anyRequest().permitAll()); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.java index 0a963a0a6f86..d45e4c6ba2dc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.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. @@ -22,14 +22,16 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.SecurityFilterChain; +import static org.springframework.security.config.Customizer.withDefaults; + @Configuration(proxyBeanMethods = false) public class MySecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.requestMatcher(EndpointRequest.toAnyEndpoint()) - .authorizeRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN")); - http.httpBasic(); + http.requestMatcher(EndpointRequest.toAnyEndpoint()); + http.authorizeRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN")); + http.httpBasic(withDefaults()); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java index cdb57f9d58d7..dd797fac09b4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java @@ -22,6 +22,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.SecurityFilterChain; @@ -32,13 +33,18 @@ public class DevProfileSecurityConfiguration { @Bean @Order(Ordered.HIGHEST_PRECEDENCE) SecurityFilterChain h2ConsoleSecurityFilterChain(HttpSecurity http) throws Exception { - // @formatter:off - return http.requestMatcher(PathRequest.toH2Console()) - // ... configuration for authorization - .csrf().disable() - .headers().frameOptions().sameOrigin().and() - .build(); - // @formatter:on + http.requestMatcher(PathRequest.toH2Console()); + http.authorizeRequests(yourCustomAuthorization()); + http.csrf((csrf) -> csrf.disable()); + http.headers((headers) -> headers.frameOptions().sameOrigin()); + return http.build(); } + // tag::customizer[] + Customizer yourCustomAuthorization() { + return (t) -> { + }; + } + // end::customizer[] + } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.java index 6e15db5f2e05..264a03d9d725 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.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,8 +26,8 @@ public class MyOAuthClientConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().authenticated(); - http.oauth2Login().redirectionEndpoint().baseUri("custom-callback"); + http.authorizeRequests((requests) -> requests.anyRequest().authenticated()); + http.oauth2Login((login) -> login.redirectionEndpoint().baseUri("custom-callback")); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.java index 05dca638ec2b..a419bb935fa2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.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. @@ -22,16 +22,18 @@ import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.web.server.SecurityWebFilterChain; +import static org.springframework.security.config.Customizer.withDefaults; + @Configuration(proxyBeanMethods = false) public class MyWebFluxSecurityConfiguration { @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - http.authorizeExchange((spec) -> { - spec.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll(); - spec.pathMatchers("/foo", "/bar").authenticated(); + http.authorizeExchange((exchange) -> { + exchange.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll(); + exchange.pathMatchers("/foo", "/bar").authenticated(); }); - http.formLogin(); + http.formLogin(withDefaults()); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.java index a02a677ea6b5..4b007e241d9b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.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. @@ -27,7 +27,7 @@ public class MySecurityConfig { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { // Customize the application security ... - http.requiresChannel().anyRequest().requiresSecure(); + http.requiresChannel((channel) -> channel.anyRequest().requiresSecure()); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MyConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MyConfiguration.java index e6d24d1bbe09..6155797b205d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MyConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MyConfiguration.java @@ -30,7 +30,7 @@ public class MyConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().authenticated(); + http.authorizeRequests((requests) -> requests.anyRequest().authenticated()); return http.build(); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MySecurityConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MySecurityConfiguration.java index 866ab0fd4cd7..f24fb8a586b7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MySecurityConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MySecurityConfiguration.java @@ -26,7 +26,7 @@ public class MySecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().authenticated(); + http.authorizeRequests((requests) -> requests.anyRequest().authenticated()); return http.build(); } From e313aa5f6c54c313dbdcc5abb02fe45b370f38e9 Mon Sep 17 00:00:00 2001 From: tudormarc <93496164+tudormarc@users.noreply.github.com> Date: Fri, 27 May 2022 16:30:52 +0300 Subject: [PATCH 052/161] Document that Lombok must be configured before our annotation processor See gh-31190 --- .../annotation-processor.adoc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc index fdfe8a909207..10a4f955ccd5 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc @@ -59,6 +59,29 @@ You could also let the AspectJ plugin run all the processing and disable annotat ---- ==== +[NOTE] +==== +If you are also using lombok in your project, you need to make sure that the `lombok` dependency is placed before the `spring-boot-configuration-processor` dependency. +Otherwise, combining `lombok` annotations with `spring-boot-configuration-processor` annotations will not have the desired result. + +[source,xml,indent=0,subs="verbatim"] +---- + + org.projectlombok + lombok + provided + + + ............... + + + org.springframework.boot + spring-boot-configuration-processor + true + +---- +==== + [[appendix.configuration-metadata.annotation-processor.automatic-metadata-generation]] From d896d995d1351f060e6bb8c7bc56d4376143a47d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 14:38:07 +0200 Subject: [PATCH 053/161] Polish contribution See gh-31190 --- .../annotation-processor.adoc | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc index 10a4f955ccd5..245669e18b85 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc @@ -61,25 +61,9 @@ You could also let the AspectJ plugin run all the processing and disable annotat [NOTE] ==== -If you are also using lombok in your project, you need to make sure that the `lombok` dependency is placed before the `spring-boot-configuration-processor` dependency. -Otherwise, combining `lombok` annotations with `spring-boot-configuration-processor` annotations will not have the desired result. - -[source,xml,indent=0,subs="verbatim"] ----- - - org.projectlombok - lombok - provided - - - ............... - - - org.springframework.boot - spring-boot-configuration-processor - true - ----- +If you are using Lombok in your project, you need to make sure that its annotation processor runs before `spring-boot-configuration-processor`. +To do so with Maven, you can list the annotation processors in the right order using the `annotationProcessors` attribute of the Maven compiler plugin. +If you are not using this attribute, and annotation processors are picked up by the dependencies available on the classpath, make sure that the `lombok` dependency is defined before the `spring-boot-configuration-processor` dependency. ==== From e05363f9b055bacbcaf916ccc632ede6abfa77e4 Mon Sep 17 00:00:00 2001 From: "Stern, Ittay (is9613)" Date: Tue, 31 May 2022 16:09:56 +0300 Subject: [PATCH 054/161] Restore Custom Favicon section in the reference guide The section about favicon was mistakenly removed in 5fceb9d and this commit reinstates it. See gh-31224 --- .../src/docs/asciidoc/anchor-rewrite.properties | 1 + .../spring-boot-docs/src/docs/asciidoc/web/servlet.adoc | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties index e3dfb57564cf..064556e01761 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties @@ -773,6 +773,7 @@ features.developing-web-applications.spring-mvc.json=web.servlet.spring-mvc.json features.developing-web-applications.spring-mvc.message-codes=web.servlet.spring-mvc.message-codes features.developing-web-applications.spring-mvc.static-content=web.servlet.spring-mvc.static-content features.developing-web-applications.spring-mvc.welcome-page=web.servlet.spring-mvc.welcome-page +features.developing-web-applications.spring-mvc.favicon=web.servlet.spring-mvc.favicon features.developing-web-applications.spring-mvc.content-negotiation=web.servlet.spring-mvc.content-negotiation features.developing-web-applications.spring-mvc.binding-initializer=web.servlet.spring-mvc.binding-initializer features.developing-web-applications.spring-mvc.template-engines=web.servlet.spring-mvc.template-engines diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc index 55df95d1fed5..02c6139afd3f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc @@ -216,6 +216,13 @@ If either is found, it is automatically used as the welcome page of the applicat +[[web.servlet.spring-mvc.favicon]] +==== Custom Favicon +As with other static resources, Spring Boot checks for a `favicon.ico` in the configured static content locations. +If such a file is present, it is automatically used as the favicon of the application. + + + [[web.servlet.spring-mvc.content-negotiation]] ==== Path Matching and Content Negotiation Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, `@GetMapping` annotations on Controller methods). From b1ccb600f3ba0b089a559a774b6247f2cc6c9d95 Mon Sep 17 00:00:00 2001 From: Anthony Vanelverdinghe Date: Wed, 8 Jun 2022 15:28:51 +0200 Subject: [PATCH 055/161] Remove reference to outdated location See gh-31276 --- .../src/docs/asciidoc/features/testing.adoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc index ff1ff7ecad74..8024b33e06ec 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc @@ -454,7 +454,7 @@ You can use `@DataCassandraTest` to test Cassandra applications. By default, it configures a `CassandraTemplate`, scans for `@Table` classes, and configures Spring Data Cassandra repositories. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataCassandraTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. -(For more about using Cassandra with Spring Boot, see "<>", earlier in this chapter.) +(For more about using Cassandra with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@DataCassandraTest` can be <>. @@ -558,7 +558,7 @@ If you prefer your test to run against a real database, you can use the `@AutoCo You can use `@JooqTest` in a similar fashion as `@JdbcTest` but for jOOQ-related tests. As jOOQ relies heavily on a Java-based schema that corresponds with the database schema, the existing `DataSource` is used. If you want to replace it with an in-memory database, you can use `@AutoConfigureTestDatabase` to override those settings. -(For more about using jOOQ with Spring Boot, see "<>", earlier in this chapter.) +(For more about using jOOQ with Spring Boot, see "<>".) Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@JooqTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. @@ -583,7 +583,7 @@ You can use `@DataMongoTest` to test MongoDB applications. By default, it configures an in-memory embedded MongoDB (if available), configures a `MongoTemplate`, scans for `@Document` classes, and configures Spring Data MongoDB repositories. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataMongoTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. -(For more about using MongoDB with Spring Boot, see "<>", earlier in this chapter.) +(For more about using MongoDB with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@DataMongoTest` can be <>. @@ -610,7 +610,7 @@ You can use `@DataNeo4jTest` to test Neo4j applications. By default, it scans for `@Node` classes, and configures Spring Data Neo4j repositories. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataNeo4jTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. -(For more about using Neo4J with Spring Boot, see "<>", earlier in this chapter.) +(For more about using Neo4J with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@DataNeo4jTest` can be <>. @@ -641,7 +641,7 @@ You can use `@DataRedisTest` to test Redis applications. By default, it scans for `@RedisHash` classes and configures Spring Data Redis repositories. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataRedisTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. -(For more about using Redis with Spring Boot, see "<>", earlier in this chapter.) +(For more about using Redis with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@DataRedisTest` can be <>. @@ -660,7 +660,7 @@ You can use `@DataLdapTest` to test LDAP applications. By default, it configures an in-memory embedded LDAP (if available), configures an `LdapTemplate`, scans for `@Entry` classes, and configures Spring Data LDAP repositories. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataLdapTest` annotation is used. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. -(For more about using LDAP with Spring Boot, see "<>", earlier in this chapter.) +(For more about using LDAP with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@DataLdapTest` can be <>. @@ -792,7 +792,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin ===== Auto-configured Spring Web Services Client Tests You can use `@WebServiceClientTest` to test applications that call web services using the Spring Web Services project. By default, it configures a mock `WebServiceServer` bean and automatically customizes your `WebServiceTemplateBuilder`. -(For more about using Web Services with Spring Boot, see "<>", earlier in this chapter.) +(For more about using Web Services with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@WebServiceClientTest` can be <>. @@ -810,7 +810,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredwebse ===== Auto-configured Spring Web Services Server Tests You can use `@WebServiceServerTest` to test applications that implement web services using the Spring Web Services project. By default, it configures a `MockWebServiceClient` bean that can be used to call your web service endpoints. -(For more about using Web Services with Spring Boot, see "<>", earlier in this chapter.) +(For more about using Web Services with Spring Boot, see "<>".) TIP: A list of the auto-configuration settings that are enabled by `@WebServiceServerTest` can be <>. From 8c9557f5526129f0fdbf97536fc2c5c51fec455c Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Wed, 8 Jun 2022 17:03:07 +0200 Subject: [PATCH 056/161] Enable Links for the Javadoc of the Gradle Plugins See gh-31279 --- .../spring-boot-tools/spring-boot-gradle-plugin/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle index 916045116623..bd1796d7ff85 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle @@ -97,6 +97,8 @@ javadoc { splitIndex = true use = true windowTitle = "Spring Boot Gradle Plugin ${project.version} API" + links "https://docs.gradle.org/$gradle.gradleVersion/javadoc/" + links "https://docs.oracle.com/javase/8/docs/api/" } } From c052a4d6a6c98e0a6b0eba13e49c3424de42109b Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Mon, 13 Jun 2022 00:29:47 +0000 Subject: [PATCH 057/161] Restrict permissions for GitHub action See gh-31344 --- .github/workflows/gradle-wrapper-validation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 405a2b306592..3e7910534b98 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,6 +1,9 @@ name: "Validate Gradle Wrapper" on: [push, pull_request] +permissions: + contents: read + jobs: validation: name: "Validation" From 1fffdbae2afce8c29e2e3e95648fba3e11867abd Mon Sep 17 00:00:00 2001 From: Anthony Vanelverdinghe Date: Fri, 10 Jun 2022 11:17:53 +0200 Subject: [PATCH 058/161] Fix typos in the reference documentation See gh-31328 --- .../spring-boot-docs/src/docs/asciidoc/data/sql.adoc | 2 +- .../spring-boot-docs/src/docs/asciidoc/web/servlet.adoc | 2 +- .../src/docs/asciidoc/web/spring-security.adoc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc index 69619c935023..b6a1d0bd4e9d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc @@ -251,7 +251,7 @@ For complete details, see the {spring-data-jpa-docs}[Spring Data JPA reference d ==== Spring Data Envers Repositories If {spring-data-envers}[Spring Data Envers] is available, JPA repositories are auto-configured to support typical Envers queries. -To use Spring Data Envers, make sure your repository extends from `RevisionRepository` as show in the following example: +To use Spring Data Envers, make sure your repository extends from `RevisionRepository` as shown in the following example: [source,java,indent=0,subs="verbatim"] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc index 02c6139afd3f..1921c4c06d44 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc @@ -369,7 +369,7 @@ You can also define a class annotated with `@ControllerAdvice` to customize the include::{docs-java}/web/servlet/springmvc/errorhandling/MyControllerAdvice.java[] ---- -In the preceding example, if `YourException` is thrown by a controller defined in the same package as `SomeController`, a JSON representation of the `CustomErrorType` POJO is used instead of the `ErrorAttributes` representation. +In the preceding example, if `MyException` is thrown by a controller defined in the same package as `SomeController`, a JSON representation of the `MyErrorBody` POJO is used instead of the `ErrorAttributes` representation. In some cases, errors handled at the controller level are not recorded by the <>. Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-security.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-security.adoc index 86113c87f75f..83af9974caf4 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-security.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-security.adoc @@ -77,7 +77,7 @@ https://oauth.net/2/[OAuth2] is a widely used authorization framework that is su [[web.security.oauth2.client]] ==== Client -If you have `spring-security-oauth2-client` on your classpath, you can take advantage of some auto-configuration to set up an OAuth2/Open ID Connect clients. +If you have `spring-security-oauth2-client` on your classpath, you can take advantage of some auto-configuration to set up OAuth2/Open ID Connect clients. This configuration makes use of the properties under `OAuth2ClientProperties`. The same properties are applicable to both servlet and reactive applications. @@ -121,7 +121,7 @@ You can register multiple OAuth2 clients and providers under the `spring.securit ---- For OpenID Connect providers that support https://openid.net/specs/openid-connect-discovery-1_0.html[OpenID Connect discovery], the configuration can be further simplified. -The provider needs to be configured with an `issuer-uri` which is the URI that the it asserts as its Issuer Identifier. +The provider needs to be configured with an `issuer-uri` which is the URI that it asserts as its Issuer Identifier. For example, if the `issuer-uri` provided is "https://example.com", then an `OpenID Provider Configuration Request` will be made to "https://example.com/.well-known/openid-configuration". The result is expected to be an `OpenID Provider Configuration Response`. The following example shows how an OpenID Connect Provider can be configured with the `issuer-uri`: From 7e2b325b368c5b74d91d6df20f549e5c0c897ac7 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 13 Jun 2022 12:36:37 -0700 Subject: [PATCH 059/161] Include auto-configuration and management import files in parent POM Update the `maven-shade-plugin` configuration to include transformation of the new `AutoConfiguration.imports` and `ManagementContextConfiguration.imports` files. Fixes gh-31316 --- .../spring-boot-starter-parent/build.gradle | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-parent/build.gradle b/spring-boot-project/spring-boot-starters/spring-boot-starter-parent/build.gradle index 6a10c7c13d82..771a53289471 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-parent/build.gradle +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-parent/build.gradle @@ -199,12 +199,18 @@ publishing.publications.withType(MavenPublication) { transformer(implementation: 'org.apache.maven.plugins.shade.resource.AppendingTransformer') { delegate.resource('META-INF/spring.handlers') } - transformer(implementation: 'org.springframework.boot.maven.PropertiesMergingResourceTransformer') { - delegate.resource('META-INF/spring.factories') - } transformer(implementation: 'org.apache.maven.plugins.shade.resource.AppendingTransformer') { delegate.resource('META-INF/spring.schemas') } + transformer(implementation: 'org.apache.maven.plugins.shade.resource.AppendingTransformer') { + delegate.resource('META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports') + } + transformer(implementation: 'org.apache.maven.plugins.shade.resource.AppendingTransformer') { + delegate.resource('META-INF/spring/org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration.imports') + } + transformer(implementation: 'org.springframework.boot.maven.PropertiesMergingResourceTransformer') { + delegate.resource('META-INF/spring.factories') + } transformer(implementation: 'org.apache.maven.plugins.shade.resource.ServicesResourceTransformer') transformer(implementation: 'org.apache.maven.plugins.shade.resource.ManifestResourceTransformer') { delegate.mainClass('${start-class}') From 378e56f1d30f1a10d50de7f340236fb0af842b1c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 13 Jun 2022 16:44:20 -0700 Subject: [PATCH 060/161] Add Order annotation to GraphQL RouterFunction beans Update GraphQL auto-configuration so that `RouterFunction` beans have and `@Order` of 0. Fixes gh-31314 --- .../GraphQlWebFluxAutoConfiguration.java | 6 ++-- .../GraphQlWebMvcAutoConfiguration.java | 2 ++ .../GraphQlWebFluxAutoConfigurationTests.java | 31 ++++++++++++++++++ .../GraphQlWebMvcAutoConfigurationTests.java | 32 +++++++++++++++++++ .../src/docs/asciidoc/web/spring-graphql.adoc | 6 +++- 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java index a9261117d0f8..70178c801634 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java @@ -38,6 +38,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.core.log.LogMessage; import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.execution.GraphQlSource; @@ -101,8 +102,9 @@ public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, } @Bean - public RouterFunction graphQlEndpoint(GraphQlHttpHandler httpHandler, GraphQlSource graphQlSource, - GraphQlProperties properties) { + @Order(0) + public RouterFunction graphQlRouterFunction(GraphQlHttpHandler httpHandler, + GraphQlSource graphQlSource, GraphQlProperties properties) { String path = properties.getPath(); logger.info(LogMessage.format("GraphQL endpoint HTTP POST %s", path)); RouterFunctions.Builder builder = RouterFunctions.route(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java index 8a9fd350b04b..15a3d46ac765 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java @@ -41,6 +41,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.core.log.LogMessage; import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.execution.GraphQlSource; @@ -106,6 +107,7 @@ public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, } @Bean + @Order(0) public RouterFunction graphQlRouterFunction(GraphQlHttpHandler httpHandler, GraphQlSource graphQlSource, GraphQlProperties properties) { String path = properties.getPath(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java index 797ec5f2abf7..2c498b56f90e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.autoconfigure.graphql.reactive; import java.util.Collections; +import java.util.Map; import java.util.function.Consumer; import graphql.schema.idl.TypeRuntimeWiring; @@ -32,6 +33,7 @@ import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.graphql.execution.RuntimeWiringConfigurer; import org.springframework.graphql.server.WebGraphQlHandler; import org.springframework.graphql.server.WebGraphQlInterceptor; @@ -41,6 +43,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.reactive.function.server.RouterFunction; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.containsString; @@ -147,6 +150,17 @@ void shouldConfigureWebSocketBeans() { .run((context) -> assertThat(context).hasSingleBean(GraphQlWebSocketHandler.class)); } + @Test + void routerFunctionShouldHaveOrderZero() throws Exception { + this.contextRunner.withUserConfiguration(CustomRouterFunctions.class).run((context) -> { + Map beans = context.getBeansOfType(RouterFunction.class); + Object[] ordered = context.getBeanProvider(RouterFunction.class).orderedStream().toArray(); + assertThat(beans.get("before")).isSameAs(ordered[0]); + assertThat(beans.get("graphQlRouterFunction")).isSameAs(ordered[1]); + assertThat(beans.get("after")).isSameAs(ordered[2]); + }); + } + private void testWithWebClient(Consumer consumer) { this.contextRunner.run((context) -> { WebTestClient client = WebTestClient.bindToApplicationContext(context).configureClient() @@ -180,4 +194,21 @@ WebGraphQlInterceptor customWebGraphQlInterceptor() { } + @Configuration + static class CustomRouterFunctions { + + @Bean + @Order(-1) + RouterFunction before() { + return (r) -> null; + } + + @Bean + @Order(1) + RouterFunction after() { + return (r) -> null; + } + + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java index 268bbee1d105..285b5e2fd2e2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java @@ -16,6 +16,8 @@ package org.springframework.boot.autoconfigure.graphql.servlet; +import java.util.Map; + import graphql.schema.idl.TypeRuntimeWiring; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; @@ -30,6 +32,7 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.graphql.execution.RuntimeWiringConfigurer; import org.springframework.graphql.server.WebGraphQlHandler; import org.springframework.graphql.server.WebGraphQlInterceptor; @@ -40,6 +43,7 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.servlet.function.RouterFunction; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; @@ -153,6 +157,17 @@ void shouldConfigureWebSocketBeans() { .run((context) -> assertThat(context).hasSingleBean(GraphQlWebSocketHandler.class)); } + @Test + void routerFunctionShouldHaveOrderZero() throws Exception { + this.contextRunner.withUserConfiguration(CustomRouterFunctions.class).run((context) -> { + Map beans = context.getBeansOfType(RouterFunction.class); + Object[] ordered = context.getBeanProvider(RouterFunction.class).orderedStream().toArray(); + assertThat(beans.get("before")).isSameAs(ordered[0]); + assertThat(beans.get("graphQlRouterFunction")).isSameAs(ordered[1]); + assertThat(beans.get("after")).isSameAs(ordered[2]); + }); + } + private void testWith(MockMvcConsumer mockMvcConsumer) { this.contextRunner.run((context) -> { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).defaultRequest( @@ -190,4 +205,21 @@ WebGraphQlInterceptor customWebGraphQlInterceptor() { } + @Configuration + static class CustomRouterFunctions { + + @Bean + @Order(-1) + RouterFunction before() { + return (r) -> null; + } + + @Bean + @Order(1) + RouterFunction after() { + return (r) -> null; + } + + } + } diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-graphql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-graphql.adoc index 16df04673188..080c7a3a738d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-graphql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-graphql.adoc @@ -83,7 +83,11 @@ are detected by Spring Boot and considered as candidates for `DataFetcher` for m [[web.graphql.transports.http-websocket]] ==== HTTP and WebSocket -The GraphQL HTTP endpoint is at HTTP POST "/graphql" by default. The path can be customized with configprop:spring.graphql.path[]. +The GraphQL HTTP endpoint is at HTTP POST "/graphql" by default. +The path can be customized with configprop:spring.graphql.path[]. + +TIP: The HTTP endpoint for both Spring MVC and Spring WebFlux is provided by a `RouterFunction` bean with an `@Order` or `0`. +If you define your own `RouterFunction` beans, you may want to add appropriate `@Order` annotations to ensure that they are sorted correctly. The GraphQL WebSocket endpoint is off by default. To enable it: From b3a46fc50e9e0f08cd5d98e90941afc0e462f394 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 13 Jun 2022 18:18:23 -0700 Subject: [PATCH 061/161] Document that placeholders should us the canonical property name form Closes gh-31309 --- .../docs/asciidoc/features/external-config.adoc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc index 3d38486405c4..010825d00933 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc @@ -458,6 +458,15 @@ The use of placeholders with and without defaults is shown in the following exam Assuming that the `username` property has not been set elsewhere, `app.description` will have the value `MyApp is a Spring Boot application written by Unknown`. +[NOTE] +==== +You should always refer to property names in the placeholder using their canonical form (kebab-case using only lowercase letters). +This will allow Spring Boot to use the same logic as it does when <> `@ConfigurationProperties`. + +For example, `${demo.item-price}` will pick up `demo.item-price` and `demo.itemPrice` forms from the `application.properties` file, as well as `DEMO_ITEMPRICE` from the system environment. +If you used `${demo.itemPrice}` instead, `demo.item-price` and `DEMO_ITEMPRICE` would not be considered. +==== + TIP: You can also use this technique to create "`short`" variants of existing Spring Boot properties. See the _<>_ how-to for details. @@ -1222,10 +1231,14 @@ The following table summarizes the features that are supported by `@Configuratio |=== [[features.external-config.typesafe-configuration-properties.vs-value-annotation.note]] -NOTE: If you do want to use `@Value`, we recommend that you refer to property names using their canonical form (kebab-case using only lowercase letters). -This will allow Spring Boot to use the same logic as it does when relaxed binding `@ConfigurationProperties`. +[NOTE] +==== +If you do want to use `@Value`, we recommend that you refer to property names using their canonical form (kebab-case using only lowercase letters). +This will allow Spring Boot to use the same logic as it does when <> `@ConfigurationProperties`. + For example, `@Value("{demo.item-price}")` will pick up `demo.item-price` and `demo.itemPrice` forms from the `application.properties` file, as well as `DEMO_ITEMPRICE` from the system environment. If you used `@Value("{demo.itemPrice}")` instead, `demo.item-price` and `DEMO_ITEMPRICE` would not be considered. +==== If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with `@ConfigurationProperties`. Doing so will provide you with structured, type-safe object that you can inject into your own beans. From 0e1417935dc8fa82adda533da2ac4efaebd698c6 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:40:51 +0200 Subject: [PATCH 062/161] Start building against Reactor 2020.0.20 snapshots See gh-31371 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 80c5e5f9e6ae..6dec8ffeb54a 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1432,7 +1432,7 @@ bom { ] } } - library("Reactor Bom", "2020.0.19") { + library("Reactor Bom", "2020.0.20-SNAPSHOT") { group("io.projectreactor") { imports = [ "reactor-bom" From 37af43cb18bde2189dee8ee87bc93cc531bd6f04 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:42:02 +0200 Subject: [PATCH 063/161] Start building against Micrometer 1.9.1 snapshots See gh-31372 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 6dec8ffeb54a..c405d8309567 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1281,7 +1281,7 @@ bom { ] } } - library("Micrometer", "1.9.0") { + library("Micrometer", "1.9.1-SNAPSHOT") { group("io.micrometer") { modules = [ "micrometer-registry-stackdriver" { From 02da20ec98889ea20d849d19f90463de31212537 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:43:52 +0200 Subject: [PATCH 064/161] Start building against Spring LDAP 2.4.1 snapshots See gh-31373 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index c405d8309567..0b0a6791f0a8 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1736,7 +1736,7 @@ bom { ] } } - library("Spring LDAP", "2.4.0") { + library("Spring LDAP", "2.4.1-SNAPSHOT") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From ba4bb2ff32210fcf62784a2bb12e7ff3fcbf2920 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:46:51 +0200 Subject: [PATCH 065/161] Start building against Spring Data 2021.2.1 snapshots See gh-31374 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0b0a6791f0a8..e77700f46e14 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1677,7 +1677,7 @@ bom { ] } } - library("Spring Data Bom", "2021.2.0") { + library("Spring Data Bom", "2021.2.1-SNAPSHOT") { prohibit("[2022.0.0-M1,)") { because "it uses Spring Framework 6" } From 7841789735f73616654c2d8ccb4d82e215de3c5a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:51:02 +0200 Subject: [PATCH 066/161] Start building against Spring Security 5.7.2 snapshots See gh-31375 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index e77700f46e14..96efc2f51c68 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1771,7 +1771,7 @@ bom { ] } } - library("Spring Security", "5.7.1") { + library("Spring Security", "5.7.2-SNAPSHOT") { prohibit("[6.0.0-M1,)") { because "it uses Spring Framework 6" } From 379344ea5967a57445aa776ffa3a0b73be34d71d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:52:04 +0200 Subject: [PATCH 067/161] Start building against Spring AMQP 2.4.6 snapshots See gh-31376 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 96efc2f51c68..3b450795f92e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1650,7 +1650,7 @@ bom { ] } } - library("Spring AMQP", "2.4.5") { + library("Spring AMQP", "2.4.6-SNAPSHOT") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From 2c7812e50486857723e35863ce23682671d53875 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:51:34 +0200 Subject: [PATCH 068/161] Start building against Reactor 2020.0.20 snapshots See gh-31346 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 4c63fa978aaf..faae32fc95d8 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1457,7 +1457,7 @@ bom { ] } } - library("Reactor Bom", "2020.0.19") { + library("Reactor Bom", "2020.0.20-SNAPSHOT") { group("io.projectreactor") { imports = [ "reactor-bom" From a2f323b4ed62de62481665ad4fee3083aa873c75 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:52:08 +0200 Subject: [PATCH 069/161] Start building against Micrometer 1.8.7 snapshots See gh-31347 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index faae32fc95d8..de662fa111e7 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1250,7 +1250,7 @@ bom { ] } } - library("Micrometer", "1.8.6") { + library("Micrometer", "1.8.7-SNAPSHOT") { group("io.micrometer") { modules = [ "micrometer-registry-stackdriver" { From bc6d2ea16d6fe52f987a9e45caab01bdaa13d5cd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:52:37 +0200 Subject: [PATCH 070/161] Start building against Spring AMQP 2.4.6 snapshots See gh-31348 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index de662fa111e7..62a154dcc0c4 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1673,7 +1673,7 @@ bom { ] } } - library("Spring AMQP", "2.4.5") { + library("Spring AMQP", "2.4.6-SNAPSHOT") { group("org.springframework.amqp") { modules = [ "spring-amqp", From d22c0a22c39ce6e75e59f26d050e6c2eb89efc34 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:53:06 +0200 Subject: [PATCH 071/161] Start building against Spring Data 2021.1.5 snapshots See gh-31349 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 62a154dcc0c4..208d2c19bc49 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1694,7 +1694,7 @@ bom { ] } } - library("Spring Data Bom", "2021.1.4") { + library("Spring Data Bom", "2021.1.5-SNAPSHOT") { group("org.springframework.data") { imports = [ "spring-data-bom" From ba572e5e16789c4572653c34cb4734e56092828c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:53:32 +0200 Subject: [PATCH 072/161] Start building against Spring Kafka 2.8.7 snapshots See gh-31350 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 208d2c19bc49..fba82ef6d98c 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1722,7 +1722,7 @@ bom { ] } } - library("Spring Kafka", "2.8.6") { + library("Spring Kafka", "2.8.7-SNAPSHOT") { group("org.springframework.kafka") { modules = [ "spring-kafka", From 342d01314a35510e662fecb7134cb69ae231b3f1 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:54:07 +0200 Subject: [PATCH 073/161] Start building against Spring Security 5.6.6 snapshots See gh-31351 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index fba82ef6d98c..afc6ecd5afc7 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1760,7 +1760,7 @@ bom { ] } } - library("Spring Security", "5.6.5") { + library("Spring Security", "5.6.6-SNAPSHOT") { group("org.springframework.security") { imports = [ "spring-security-bom" From 2f40c52d810932ec7d65f413dc8c66024276f9a1 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jun 2022 12:54:34 +0200 Subject: [PATCH 074/161] Start building against Spring Session 2021.1.4 snapshots See gh-31352 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index afc6ecd5afc7..3efbfd592f45 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1767,7 +1767,7 @@ bom { ] } } - library("Spring Session Bom", "2021.1.3") { + library("Spring Session Bom", "2021.1.4-SNAPSHOT") { group("org.springframework.session") { imports = [ "spring-session-bom" From 97e0c8e79cad2454537ed14fbf084577fb766230 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Jun 2022 07:53:04 +0200 Subject: [PATCH 075/161] Start building against Spring Kafka 2.8.7 snapshots See gh-31377 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 3b450795f92e..bead84ec3c71 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1725,7 +1725,7 @@ bom { ] } } - library("Spring Kafka", "2.8.6") { + library("Spring Kafka", "2.8.7-SNAPSHOT") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From 5d7cab09b86a9128d0ada45d9abe671d52465e71 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Jun 2022 10:37:35 +0100 Subject: [PATCH 076/161] Revert BindConverter changes that are now handled by Framework See gh-28592 and spring-projects/spring-framework#28609 Closes gh-31343 --- .../boot/context/properties/bind/BindConverter.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java index 430270b89cf6..cdabe1d990d5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java @@ -42,7 +42,6 @@ import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.ConditionalGenericConverter; import org.springframework.core.convert.support.GenericConversionService; -import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; /** @@ -107,10 +106,7 @@ private Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor for (ConversionService delegate : this.delegates) { try { if (delegate.canConvert(sourceType, targetType)) { - Object converted = delegate.convert(source, sourceType, targetType); - if (ClassUtils.isAssignableValue(targetType.getType(), converted)) { - return converted; - } + return delegate.convert(source, sourceType, targetType); } } catch (ConversionException ex) { From 2094722e5d64e116a91a31086861aa0795fda8e8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Jun 2022 11:52:06 +0100 Subject: [PATCH 077/161] Remove duplicate content from "The Spring WebFlux Framework" Closes gh-31378 --- .../src/docs/asciidoc/web/reactive.adoc | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc index dd1498992a07..e291c5f8de4e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc @@ -39,28 +39,6 @@ This behavior has been chosen because many Spring developers add `spring-boot-st You can still enforce your choice by setting the chosen application type to `SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)`. -"`WebFlux.fn`", the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: - -[source,java,indent=0,subs="verbatim"] ----- -include::{docs-java}/web/reactive/webflux/MyRoutingConfiguration.java[] ----- - -[source,java,indent=0,subs="verbatim"] ----- -include::{docs-java}/web/reactive/webflux/MyUserHandler.java[] ----- - -WebFlux is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web-reactive.html#webflux-fn[reference documentation]. - -TIP: You can define as many `RouterFunction` beans as you like to modularize the definition of the router. -Beans can be ordered if you need to apply a precedence. - -To get started, add the `spring-boot-starter-webflux` module to your application. - -NOTE: Adding both `spring-boot-starter-web` and `spring-boot-starter-webflux` modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. -This behavior has been chosen because many Spring developers add `spring-boot-starter-webflux` to their Spring MVC application to use the reactive `WebClient`. -You can still enforce your choice by setting the chosen application type to `SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)`. [[web.reactive.webflux.auto-configuration]] ==== Spring WebFlux Auto-configuration From 9f8a262e6bdfb75ea8b9a123ee3b7d25d7a672d9 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 14 Jun 2022 09:30:13 -0700 Subject: [PATCH 078/161] Log a warning when a health indicator takes too long to run Update `HealthEndpointSupport` so that it logs a warning if a health indicator takes too long to respond. Fixes gh-31231 --- .../health/HealthEndpointConfiguration.java | 7 ++-- .../health/HealthEndpointProperties.java | 29 +++++++++++++- ...ointReactiveWebExtensionConfiguration.java | 6 ++- ...althEndpointWebExtensionConfiguration.java | 5 ++- ...loudFoundryWebEndpointDiscovererTests.java | 4 +- .../HealthEndpointDocumentationTests.java | 4 +- .../boot/actuate/health/HealthEndpoint.java | 20 +++++++++- .../actuate/health/HealthEndpointSupport.java | 40 +++++++++++++++++-- .../health/HealthEndpointWebExtension.java | 20 +++++++++- .../ReactiveHealthEndpointWebExtension.java | 20 +++++++++- .../health/HealthEndpointSupportTests.java | 12 ++++-- .../actuate/health/HealthEndpointTests.java | 33 ++++++++++++--- .../HealthEndpointWebExtensionTests.java | 12 +++--- .../HealthEndpointWebIntegrationTests.java | 9 +++-- ...activeHealthEndpointWebExtensionTests.java | 9 +++-- .../src/docs/asciidoc/actuator/endpoints.adoc | 4 ++ 16 files changed, 192 insertions(+), 42 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.java index 0190380e57fd..a63d67739e34 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.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. @@ -88,8 +88,9 @@ HealthContributorRegistry healthContributorRegistry(ApplicationContext applicati @Bean @ConditionalOnMissingBean - HealthEndpoint healthEndpoint(HealthContributorRegistry registry, HealthEndpointGroups groups) { - return new HealthEndpoint(registry, groups); + HealthEndpoint healthEndpoint(HealthContributorRegistry registry, HealthEndpointGroups groups, + HealthEndpointProperties properties) { + return new HealthEndpoint(registry, groups, properties.getLogging().getSlowIndicatorThreshold()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java index d536a89f8cb0..9b5466bfe89e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.autoconfigure.health; +import java.time.Duration; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -43,6 +44,8 @@ public class HealthEndpointProperties extends HealthProperties { */ private Map group = new LinkedHashMap<>(); + private Logging logging = new Logging(); + @Override public Show getShowDetails() { return this.showDetails; @@ -56,6 +59,10 @@ public Map getGroup() { return this.group; } + public Logging getLogging() { + return this.logging; + } + /** * A health endpoint group. */ @@ -124,4 +131,24 @@ public void setAdditionalPath(String additionalPath) { } + /** + * Health logging properties. + */ + public static class Logging { + + /** + * Threshold after which a warning will be logged for slow health indicators. + */ + Duration slowIndicatorThreshold = Duration.ofSeconds(10); + + public Duration getSlowIndicatorThreshold() { + return this.slowIndicatorThreshold; + } + + public void setSlowIndicatorThreshold(Duration slowIndicatorThreshold) { + this.slowIndicatorThreshold = slowIndicatorThreshold; + } + + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointReactiveWebExtensionConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointReactiveWebExtensionConfiguration.java index 462047629954..792c9d0f7e44 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointReactiveWebExtensionConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointReactiveWebExtensionConfiguration.java @@ -53,8 +53,10 @@ class HealthEndpointReactiveWebExtensionConfiguration { @ConditionalOnMissingBean @ConditionalOnBean(HealthEndpoint.class) ReactiveHealthEndpointWebExtension reactiveHealthEndpointWebExtension( - ReactiveHealthContributorRegistry reactiveHealthContributorRegistry, HealthEndpointGroups groups) { - return new ReactiveHealthEndpointWebExtension(reactiveHealthContributorRegistry, groups); + ReactiveHealthContributorRegistry reactiveHealthContributorRegistry, HealthEndpointGroups groups, + HealthEndpointProperties properties) { + return new ReactiveHealthEndpointWebExtension(reactiveHealthContributorRegistry, groups, + properties.getLogging().getSlowIndicatorThreshold()); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java index 516fec82b6b9..857b6282959f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java @@ -72,8 +72,9 @@ class HealthEndpointWebExtensionConfiguration { @Bean @ConditionalOnMissingBean HealthEndpointWebExtension healthEndpointWebExtension(HealthContributorRegistry healthContributorRegistry, - HealthEndpointGroups groups) { - return new HealthEndpointWebExtension(healthContributorRegistry, groups); + HealthEndpointGroups groups, HealthEndpointProperties properties) { + return new HealthEndpointWebExtension(healthContributorRegistry, groups, + properties.getLogging().getSlowIndicatorThreshold()); } private static ExposableWebEndpoint getHealthEndpoint(WebEndpointsSupplier webEndpointsSupplier) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java index 84b9f4c62bf6..cf3a9494ceec 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.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. @@ -113,7 +113,7 @@ TestEndpointWebExtension testEndpointWebExtension() { HealthEndpoint healthEndpoint() { HealthContributorRegistry registry = mock(HealthContributorRegistry.class); HealthEndpointGroups groups = mock(HealthEndpointGroups.class); - return new HealthEndpoint(registry, groups); + return new HealthEndpoint(registry, groups, null); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java index dae4df571097..a512ca7a1ba1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.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. @@ -111,7 +111,7 @@ HealthEndpoint healthEndpoint(Map healthContributors) HealthContributorRegistry registry = new DefaultHealthContributorRegistry(healthContributors); HealthEndpointGroup primary = new TestHealthEndpointGroup(); HealthEndpointGroups groups = HealthEndpointGroups.of(primary, Collections.emptyMap()); - return new HealthEndpoint(registry, groups); + return new HealthEndpoint(registry, groups, null); } @Bean diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java index 4fcd7d4b7d34..d2f7eae830a8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.health; +import java.time.Duration; import java.util.Map; import java.util.Set; @@ -51,9 +52,24 @@ public class HealthEndpoint extends HealthEndpointSupport { + private static final Log logger = LogFactory.getLog(HealthEndpointSupport.class); + static final Health DEFAULT_HEALTH = Health.up().build(); private final ContributorRegistry registry; private final HealthEndpointGroups groups; + private Duration slowIndicatorLoggingThreshold; + /** * Create a new {@link HealthEndpointSupport} instance. * @param registry the health contributor registry * @param groups the health endpoint groups + * @param slowIndicatorLoggingThreshold duration after which slow health indicator + * logging should occur */ - HealthEndpointSupport(ContributorRegistry registry, HealthEndpointGroups groups) { + HealthEndpointSupport(ContributorRegistry registry, HealthEndpointGroups groups, + Duration slowIndicatorLoggingThreshold) { Assert.notNull(registry, "Registry must not be null"); Assert.notNull(groups, "Groups must not be null"); this.registry = registry; this.groups = groups; + this.slowIndicatorLoggingThreshold = slowIndicatorLoggingThreshold; } HealthResult getHealth(ApiVersion apiVersion, WebServerNamespace serverNamespace, @@ -127,7 +142,7 @@ private T getContribution(ApiVersion apiVersion, HealthEndpointGroup group, Stri showDetails, groupNames); } if (contributor != null && (name.isEmpty() || group.isMember(name))) { - return getHealth((C) contributor, showDetails); + return getLoggedHealth((C) contributor, name, showDetails); } return null; } @@ -151,6 +166,25 @@ private T getAggregateContribution(ApiVersion apiVersion, HealthEndpointGroup gr groupNames); } + private T getLoggedHealth(C contributor, String name, boolean showDetails) { + Instant start = Instant.now(); + try { + return getHealth(contributor, showDetails); + } + finally { + if (logger.isWarnEnabled() && this.slowIndicatorLoggingThreshold != null) { + Duration duration = Duration.between(start, Instant.now()); + if (duration.compareTo(this.slowIndicatorLoggingThreshold) > 0) { + String contributorClassName = contributor.getClass().getName(); + Object contributorIdentifier = (!StringUtils.hasLength(name)) ? contributorClassName + : contributor.getClass().getName() + " (" + name + ")"; + logger.warn(LogMessage.format("Health contributor %s took %s to respond", contributorIdentifier, + DurationStyle.SIMPLE.print(duration))); + } + } + } + } + protected abstract T getHealth(C contributor, boolean includeDetails); protected abstract T aggregateContributions(ApiVersion apiVersion, Map contributions, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java index 3c44d51137cd..b96f3c07acde 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.health; +import java.time.Duration; import java.util.Arrays; import java.util.Map; import java.util.Set; @@ -51,9 +52,24 @@ public class HealthEndpointWebExtension extends HealthEndpointSupport the support type * @param the registry type * @param the contributor type * @param the contributed health component type * @author Phillip Webb * @author Madhura Bhave */ -abstract class HealthEndpointSupportTests, C, T> { +abstract class HealthEndpointSupportTests, R extends ContributorRegistry, C, T> { final R registry; @@ -352,7 +354,11 @@ void getComponentHealthWhenGroupHasAdditionalPathAndShowComponentsFalse() { assertThat(result).isEqualTo(null); } - protected abstract HealthEndpointSupport create(R registry, HealthEndpointGroups groups); + protected final S create(R registry, HealthEndpointGroups groups) { + return create(registry, groups, null); + } + + protected abstract S create(R registry, HealthEndpointGroups groups, Duration slowIndicatorLoggingThreshold); protected abstract R createRegistry(); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java index 776d29c83f31..02d20a5955b4 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.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. @@ -16,12 +16,16 @@ package org.springframework.boot.actuate.health; +import java.time.Duration; import java.util.Collections; import java.util.Map; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.actuate.health.HealthEndpointSupport.HealthResult; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -32,8 +36,9 @@ * @author Phillip Webb * @author Scott Frederick */ -class HealthEndpointTests - extends HealthEndpointSupportTests { +@ExtendWith(OutputCaptureExtension.class) +class HealthEndpointTests extends + HealthEndpointSupportTests { @Test void healthReturnsSystemHealth() { @@ -66,9 +71,27 @@ void healthWhenPathExistsReturnsHealth() { assertThat(health).isEqualTo(this.up); } + @Test + void healthWhenIndicatorIsSlow(CapturedOutput output) { + HealthIndicator indicator = () -> { + try { + Thread.sleep(100); + } + catch (InterruptedException ex) { + } + return this.up; + }; + this.registry.registerContributor("test", indicator); + create(this.registry, this.groups, Duration.ofMillis(10)).health(); + assertThat(output).contains("Health contributor"); + assertThat(output).contains("to respond"); + + } + @Override - protected HealthEndpoint create(HealthContributorRegistry registry, HealthEndpointGroups groups) { - return new HealthEndpoint(registry, groups); + protected HealthEndpoint create(HealthContributorRegistry registry, HealthEndpointGroups groups, + Duration slowIndicatorLoggingThreshold) { + return new HealthEndpoint(registry, groups, slowIndicatorLoggingThreshold); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebExtensionTests.java index 778b2592f886..56f44169ce0d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebExtensionTests.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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.health; +import java.time.Duration; import java.util.Collections; import java.util.Map; @@ -36,8 +37,8 @@ * @author Phillip Webb * @author Scott Frederick */ -class HealthEndpointWebExtensionTests - extends HealthEndpointSupportTests { +class HealthEndpointWebExtensionTests extends + HealthEndpointSupportTests { @Test void healthReturnsSystemHealth() { @@ -81,8 +82,9 @@ void healthWhenPathExistsReturnsHealth() { } @Override - protected HealthEndpointWebExtension create(HealthContributorRegistry registry, HealthEndpointGroups groups) { - return new HealthEndpointWebExtension(registry, groups); + protected HealthEndpointWebExtension create(HealthContributorRegistry registry, HealthEndpointGroups groups, + Duration slowIndicatorLoggingThreshold) { + return new HealthEndpointWebExtension(registry, groups, slowIndicatorLoggingThreshold); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java index ab6c24431eb9..4db81a4971bd 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.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. @@ -188,14 +188,14 @@ ReactiveHealthContributorRegistry reactiveHealthContributorRegistry( @Bean HealthEndpoint healthEndpoint(HealthContributorRegistry healthContributorRegistry, HealthEndpointGroups healthEndpointGroups) { - return new HealthEndpoint(healthContributorRegistry, healthEndpointGroups); + return new HealthEndpoint(healthContributorRegistry, healthEndpointGroups, null); } @Bean @ConditionalOnWebApplication(type = Type.SERVLET) HealthEndpointWebExtension healthWebEndpointExtension(HealthContributorRegistry healthContributorRegistry, HealthEndpointGroups healthEndpointGroups) { - return new HealthEndpointWebExtension(healthContributorRegistry, healthEndpointGroups); + return new HealthEndpointWebExtension(healthContributorRegistry, healthEndpointGroups, null); } @Bean @@ -203,7 +203,8 @@ HealthEndpointWebExtension healthWebEndpointExtension(HealthContributorRegistry ReactiveHealthEndpointWebExtension reactiveHealthWebEndpointExtension( ReactiveHealthContributorRegistry reactiveHealthContributorRegistry, HealthEndpointGroups healthEndpointGroups) { - return new ReactiveHealthEndpointWebExtension(reactiveHealthContributorRegistry, healthEndpointGroups); + return new ReactiveHealthEndpointWebExtension(reactiveHealthContributorRegistry, healthEndpointGroups, + null); } @Bean diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtensionTests.java index 38acbd1acee9..92c7e0066546 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtensionTests.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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.health; +import java.time.Duration; import java.util.Collections; import java.util.Map; @@ -37,7 +38,7 @@ * @author Scott Frederick */ class ReactiveHealthEndpointWebExtensionTests extends - HealthEndpointSupportTests> { + HealthEndpointSupportTests> { @Test void healthReturnsSystemHealth() { @@ -82,8 +83,8 @@ void healthWhenPathExistsReturnsHealth() { @Override protected ReactiveHealthEndpointWebExtension create(ReactiveHealthContributorRegistry registry, - HealthEndpointGroups groups) { - return new ReactiveHealthEndpointWebExtension(registry, groups); + HealthEndpointGroups groups, Duration slowIndicatorLoggingThreshold) { + return new ReactiveHealthEndpointWebExtension(registry, groups, slowIndicatorLoggingThreshold); } @Override diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc index f79536774c67..acd022903664 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc @@ -767,6 +767,10 @@ include::{docs-java}/actuator/endpoints/health/writingcustomhealthindicators/MyH NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists. In the preceding example, the health information is available in an entry named `my`. +TIP: Health indicators are usually called over HTTP and need to respond before any connection timeouts. +Spring Boot will log a warning message for any health indicator that takes longer than 10 seconds to respond. +If you want to configure this threshold, you can use the configprop:management.endpoint.health.logging.slow-indicator-threshold[] property + In addition to Spring Boot's predefined {spring-boot-actuator-module-code}/health/Status.java[`Status`] types, `Health` can return a custom `Status` that represents a new system state. In such cases, you also need to provide a custom implementation of the {spring-boot-actuator-module-code}/health/StatusAggregator.java[`StatusAggregator`] interface, or you must configure the default implementation by using the configprop:management.endpoint.health.status.order[] configuration property. From 5a028e059c0af58d4d8188d499cfc1bf8612965f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Jun 2022 18:58:16 +0100 Subject: [PATCH 079/161] Align buildSrc's Kotlin version with the main build Closes gh-31387 --- buildSrc/build.gradle | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a4cf101356df..d3a3c3b1c973 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -13,6 +13,15 @@ repositories { sourceCompatibility = 1.8 targetCompatibility = 1.8 +ext { + def propertiesFile = new File(new File("$projectDir").parentFile, "gradle.properties") + propertiesFile.withInputStream { + def properties = new Properties() + properties.load(it) + set("kotlinVersion", properties["kotlinVersion"]) + } +} + dependencies { checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}" implementation(platform("org.springframework:spring-framework-bom:5.3.15")) @@ -21,8 +30,8 @@ dependencies { implementation("org.apache.maven:maven-embedder:3.6.2") implementation("org.asciidoctor:asciidoctor-gradle-jvm:3.3.2") implementation("org.gradle:test-retry-gradle-plugin:1.4.0") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0") - implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") + implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}") implementation("org.springframework:spring-core") implementation("org.springframework:spring-web") implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}") From cb4f5ed08e702915f38420d34d14a159453f68bc Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 15 Jun 2022 08:12:33 +0200 Subject: [PATCH 080/161] Upgrade to Reactor 2020.0.20 Closes gh-31346 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 3efbfd592f45..0e14cbf4d94b 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1457,7 +1457,7 @@ bom { ] } } - library("Reactor Bom", "2020.0.20-SNAPSHOT") { + library("Reactor Bom", "2020.0.20") { group("io.projectreactor") { imports = [ "reactor-bom" From 1bf2e0bb8e61735081f2bc2ee2425c0490b4361f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 15 Jun 2022 08:13:35 +0200 Subject: [PATCH 081/161] Upgrade to Reactor 2020.0.20 Closes gh-31371 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index bead84ec3c71..928f3528f348 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1432,7 +1432,7 @@ bom { ] } } - library("Reactor Bom", "2020.0.20-SNAPSHOT") { + library("Reactor Bom", "2020.0.20") { group("io.projectreactor") { imports = [ "reactor-bom" From 49b71005de541180d6a9f5ae56b4860e8a85943a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 15 Jun 2022 11:06:29 +0200 Subject: [PATCH 082/161] Upgrade to Spring Framework 5.3.21 Closes gh-31318 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0e14cbf4d94b..b3dd33fe2de5 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1701,7 +1701,7 @@ bom { ] } } - library("Spring Framework", "5.3.21-SNAPSHOT") { + library("Spring Framework", "5.3.21") { group("org.springframework") { imports = [ "spring-framework-bom" From 8c7923da6adb242951ecf6e1a491244f728fe65b Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 15 Jun 2022 11:07:33 +0200 Subject: [PATCH 083/161] Upgrade to Spring Framework 5.3.21 Closes gh-31319 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 928f3528f348..e13d5876b0d9 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1687,7 +1687,7 @@ bom { ] } } - library("Spring Framework", "5.3.21-SNAPSHOT") { + library("Spring Framework", "5.3.21") { prohibit("[6.0.0-M1,)") { because "we upgrade in Spring Boot 3.x" } From b42f056ddbfd5041ef80d2d909dd2f5e51ec3ff0 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 14 Jun 2022 20:46:51 -0700 Subject: [PATCH 084/161] Don't close jar files early Update `JarFile` and related classes so that `close()` is not longer called early. Prior to this commit, we would always immediately close the underlying jar file to prevent file locking issues with our build. This causes issues on certain JVMs when they attempt to verify a signed jar. The file lock issues have now been solved by returning a custom input stream from `JarUrlConnection` which captures and delegates the close method. Fixes gh-29356 --- .../boot/loader/jar/JarFile.java | 42 +++++++++++++------ .../boot/loader/jar/JarFileWrapper.java | 5 +-- .../boot/loader/jar/JarURLConnection.java | 18 +++++++- .../boot/loader/jar/JarFileWrapperTests.java | 3 +- .../spring-boot-loader-tests/build.gradle | 16 ++++++- .../build.gradle | 22 ++++++++++ .../settings.gradle | 15 +++++++ .../LoaderSignedJarTestApplication.java | 36 ++++++++++++++++ .../boot/loader/LoaderIntegrationTests.java | 29 +++++++++---- 9 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/settings.gradle create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/src/main/java/org/springframework/boot/loaderapp/LoaderSignedJarTestApplication.java diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index 81386386f931..65727df35d0f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.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,8 +26,11 @@ import java.net.URLStreamHandler; import java.net.URLStreamHandlerFactory; import java.security.Permission; +import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; +import java.util.List; import java.util.Spliterator; import java.util.Spliterators; import java.util.function.Supplier; @@ -93,6 +96,8 @@ public class JarFile extends AbstractJarFile implements Iterable nestedJars = Collections.synchronizedList(new ArrayList<>()); + /** * Create a new {@link JarFile} backed by the specified file. * @param file the root jar file @@ -128,9 +133,6 @@ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccess private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter, JarFileType type, Supplier manifestSupplier) throws IOException { super(rootFile.getFile()); - if (System.getSecurityManager() == null) { - super.close(); - } this.rootFile = rootFile; this.pathFromRoot = pathFromRoot; CentralDirectoryParser parser = new CentralDirectoryParser(); @@ -142,8 +144,7 @@ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccess } catch (RuntimeException ex) { try { - this.rootFile.close(); - super.close(); + close(); } catch (IOException ioex) { } @@ -188,8 +189,13 @@ public void visitEnd() { JarFileWrapper getWrapper() throws IOException { JarFileWrapper wrapper = this.wrapper; if (wrapper == null) { - wrapper = new JarFileWrapper(this); - this.wrapper = wrapper; + synchronized (this) { + if (this.wrapper != null) { + return this.wrapper; + } + wrapper = new JarFileWrapper(this); + this.wrapper = wrapper; + } } return wrapper; } @@ -334,8 +340,10 @@ private JarFile createJarFileFromFileEntry(JarEntry entry) throws IOException { + "mechanism used to create your executable jar file"); } RandomAccessData entryData = this.entries.getEntryData(entry.getName()); - return new JarFile(this.rootFile, this.pathFromRoot + "!/" + entry.getName(), entryData, + JarFile nestedJar = new JarFile(this.rootFile, this.pathFromRoot + "!/" + entry.getName(), entryData, JarFileType.NESTED_JAR); + this.nestedJars.add(nestedJar); + return nestedJar; } @Override @@ -355,11 +363,19 @@ public void close() throws IOException { if (this.closed) { return; } - super.close(); - if (this.type == JarFileType.DIRECT) { - this.rootFile.close(); + synchronized (this) { + super.close(); + if (this.type == JarFileType.DIRECT) { + this.rootFile.close(); + } + if (this.wrapper != null) { + this.wrapper.close(); + } + for (JarFile nestedJar : this.nestedJars) { + nestedJar.close(); + } + this.closed = true; } - this.closed = true; } private void ensureOpen() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java index ebc897985553..d5c2f2ca4763 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.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. @@ -40,9 +40,6 @@ class JarFileWrapper extends AbstractJarFile { JarFileWrapper(JarFile parent) throws IOException { super(parent.getRootJarFile().getFile()); this.parent = parent; - if (System.getSecurityManager() == null) { - super.close(); - } } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 5e3a4f7a80c8..a7ba89923182 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.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. @@ -18,6 +18,7 @@ import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; +import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -165,7 +166,7 @@ public InputStream getInputStream() throws IOException { if (inputStream == null) { throwFileNotFound(this.jarEntryName, this.jarFile); } - return inputStream; + return new ConnectionInputStream(inputStream); } private void throwFileNotFound(Object entry, AbstractJarFile jarFile) throws FileNotFoundException { @@ -290,6 +291,19 @@ private static JarURLConnection notFound(JarFile jarFile, JarEntryName jarEntryN return new JarURLConnection(null, jarFile, jarEntryName); } + private class ConnectionInputStream extends FilterInputStream { + + ConnectionInputStream(InputStream in) { + super(in); + } + + @Override + public void close() throws IOException { + JarURLConnection.this.jarFile.close(); + } + + } + /** * A JarEntryName parsed from a URL String. */ diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java index 7da6716b00a9..6cc4eb28d240 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.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. @@ -61,6 +61,7 @@ void setup(@TempDir File temp) throws Exception { @AfterEach void cleanup() throws Exception { this.parent.close(); + this.wrapper.close(); } private File createTempJar(File temp) throws IOException { diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle index 7c4095f73b1a..8cb06000b48f 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle @@ -14,6 +14,8 @@ dependencies { app project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-tools:spring-boot-gradle-plugin", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-web", configuration: "mavenRepository") + app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter", configuration: "mavenRepository") + app("org.bouncycastle:bcprov-jdk15on:1.70") intTestImplementation(enforcedPlatform(project(":spring-boot-project:spring-boot-parent"))) intTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) @@ -39,6 +41,18 @@ task buildApp(type: GradleBuild) { tasks = ["build"] } +task syncSignedJarUnpackAppSource(type: org.springframework.boot.build.SyncAppSource) { + sourceDirectory = file("spring-boot-loader-tests-signed-jar-unpack-app") + destinationDirectory = file("${buildDir}/spring-boot-loader-tests-signed-jar-unpack-app") +} + +task buildSignedJarUnpackApp(type: GradleBuild) { + dependsOn syncSignedJarUnpackAppSource, syncMavenRepository + dir = "${buildDir}/spring-boot-loader-tests-signed-jar-unpack-app" + startParameter.buildCacheEnabled = false + tasks = ["build"] +} + intTest { - dependsOn buildApp + dependsOn buildApp, buildSignedJarUnpackApp } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle new file mode 100644 index 000000000000..a7787a1b8444 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle @@ -0,0 +1,22 @@ +plugins { + id "java" + id "org.springframework.boot" +} + +apply plugin: "io.spring.dependency-management" + +repositories { + maven { url "file:${rootDir}/../int-test-maven-repository"} + mavenCentral() + maven { url "https://repo.spring.io/snapshot" } + maven { url "https://repo.spring.io/milestone" } +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter") + implementation("org.bouncycastle:bcprov-jdk15on:1.70") +} + +bootJar { + requiresUnpack '**/bcprov-jdk15on-*.jar' +} \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/settings.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/settings.gradle new file mode 100644 index 000000000000..06d9554ad0d6 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + maven { url "file:${rootDir}/../int-test-maven-repository"} + mavenCentral() + maven { url "https://repo.spring.io/snapshot" } + maven { url "https://repo.spring.io/milestone" } + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "org.springframework.boot") { + useModule "org.springframework.boot:spring-boot-gradle-plugin:${requested.version}" + } + } + } +} \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/src/main/java/org/springframework/boot/loaderapp/LoaderSignedJarTestApplication.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/src/main/java/org/springframework/boot/loaderapp/LoaderSignedJarTestApplication.java new file mode 100644 index 000000000000..ce050ba586cb --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/src/main/java/org/springframework/boot/loaderapp/LoaderSignedJarTestApplication.java @@ -0,0 +1,36 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.loaderapp; + +import java.security.Security; +import javax.crypto.Cipher; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class LoaderSignedJarTestApplication { + + public static void main(String[] args) throws Exception { + Security.addProvider(new BouncyCastleProvider()); + Cipher.getInstance("AES/CBC/PKCS5Padding","BC"); + System.out.println("Legion of the Bouncy Castle"); + SpringApplication.run(LoaderSignedJarTestApplication.class, args); + } + +} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/java/org/springframework/boot/loader/LoaderIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/java/org/springframework/boot/loader/LoaderIntegrationTests.java index 8aa27b2efdcd..e4bce38694fe 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/java/org/springframework/boot/loader/LoaderIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/src/intTest/java/org/springframework/boot/loader/LoaderIntegrationTests.java @@ -51,7 +51,7 @@ class LoaderIntegrationTests { @ParameterizedTest @MethodSource("javaRuntimes") void readUrlsWithoutWarning(JavaRuntime javaRuntime) { - try (GenericContainer container = createContainer(javaRuntime)) { + try (GenericContainer container = createContainer(javaRuntime, "spring-boot-loader-tests-app")) { container.start(); System.out.println(this.output.toUtf8String()); assertThat(this.output.toUtf8String()).contains(">>>>> 287649 BYTES from").doesNotContain("WARNING:") @@ -59,17 +59,32 @@ void readUrlsWithoutWarning(JavaRuntime javaRuntime) { } } - private GenericContainer createContainer(JavaRuntime javaRuntime) { + @ParameterizedTest + @MethodSource("javaRuntimes") + void runSignedJarWhenUnpacked(JavaRuntime javaRuntime) { + try (GenericContainer container = createContainer(javaRuntime, + "spring-boot-loader-tests-signed-jar-unpack-app")) { + container.start(); + System.out.println(this.output.toUtf8String()); + assertThat(this.output.toUtf8String()).contains("Legion of the Bouncy Castle"); + } + } + + private GenericContainer createContainer(JavaRuntime javaRuntime, String name) { return javaRuntime.getContainer().withLogConsumer(this.output) - .withCopyFileToContainer(MountableFile.forHostPath(findApplication().toPath()), "/app.jar") + .withCopyFileToContainer(findApplication(name), "/app.jar") .withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5))) .withCommand("java", "-jar", "app.jar"); } - private File findApplication() { - String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-loader-tests-app"); - File jar = new File(name); - Assert.state(jar.isFile(), () -> "Could not find " + name + ". Have you built it?"); + private MountableFile findApplication(String name) { + return MountableFile.forHostPath(findJarFile(name).toPath()); + } + + private File findJarFile(String name) { + String path = String.format("build/%1$s/build/libs/%1$s.jar", name); + File jar = new File(path); + Assert.state(jar.isFile(), () -> "Could not find " + path + ". Have you built it?"); return jar; } From 7e6acfd2abf3ebd3137f14b2ab150c1d30014ec7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 16 Jun 2022 11:03:51 +0200 Subject: [PATCH 085/161] Upgrade to Micrometer 1.8.7 Closes gh-31347 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index b3dd33fe2de5..c47608adc0c3 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1250,7 +1250,7 @@ bom { ] } } - library("Micrometer", "1.8.7-SNAPSHOT") { + library("Micrometer", "1.8.7") { group("io.micrometer") { modules = [ "micrometer-registry-stackdriver" { From e5bb1cd108398ca038effea84a856125dc3f7209 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 16 Jun 2022 11:04:42 +0200 Subject: [PATCH 086/161] Upgrade to Micrometer 1.9.1 Closes gh-31372 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index e13d5876b0d9..5331ec05feab 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1281,7 +1281,7 @@ bom { ] } } - library("Micrometer", "1.9.1-SNAPSHOT") { + library("Micrometer", "1.9.1") { group("io.micrometer") { modules = [ "micrometer-registry-stackdriver" { From e8a1a0399a0208e877056bcc7c33a42eb65c89ef Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 16 Jun 2022 03:29:18 +0200 Subject: [PATCH 087/161] Upgrade to Bouncycastle 1.71 Closes gh-31400 --- ci/images/releasescripts/pom.xml | 4 ++-- .../spring-boot-tools/spring-boot-loader/build.gradle | 2 +- .../build.gradle | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/images/releasescripts/pom.xml b/ci/images/releasescripts/pom.xml index 746f0593f72f..48b4efa69b34 100644 --- a/ci/images/releasescripts/pom.xml +++ b/ci/images/releasescripts/pom.xml @@ -21,8 +21,8 @@ org.bouncycastle - bcpg-jdk15to18 - 1.68 + bcpg-jdk18on + 1.71 org.springframework.boot diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle index 1a03bb4eda0a..2992e00afed9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle @@ -17,6 +17,6 @@ dependencies { testImplementation("org.springframework:spring-test") testRuntimeOnly("ch.qos.logback:logback-classic") - testRuntimeOnly("org.bouncycastle:bcprov-jdk16:1.46") + testRuntimeOnly("org.bouncycastle:bcprov-jdk18on:1.71") testRuntimeOnly("org.springframework:spring-webmvc") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle index a7787a1b8444..84a7c507ed03 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle @@ -14,7 +14,7 @@ repositories { dependencies { implementation("org.springframework.boot:spring-boot-starter") - implementation("org.bouncycastle:bcprov-jdk15on:1.70") + implementation("org.bouncycastle:bcprov-jdk18on:1.71") } bootJar { From a1cc5bf2389fec28d8bc18455d7c04b43d434a39 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Jun 2022 21:52:32 +0100 Subject: [PATCH 088/161] Allow multiple JWS algorithms to be configured Closes gh-31321 --- .../OAuth2ResourceServerProperties.java | 21 ++++-- ...eOAuth2ResourceServerJwkConfiguration.java | 23 +++++- .../OAuth2ResourceServerJwtConfiguration.java | 22 +++++- ...itional-spring-configuration-metadata.json | 5 ++ ...2ResourceServerAutoConfigurationTests.java | 52 ++++++++++++++ ...2ResourceServerAutoConfigurationTests.java | 70 +++++++++++++++++++ 6 files changed, 184 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java index e876d1433b57..7c1c93756621 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java @@ -20,9 +20,11 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -59,9 +61,9 @@ public static class Jwt { private String jwkSetUri; /** - * JSON Web Algorithm used for verifying the digital signatures. + * JSON Web Algorithms used for verifying the digital signatures. */ - private String jwsAlgorithm = "RS256"; + private List jwsAlgorithms = Arrays.asList("RS256"); /** * URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 @@ -87,12 +89,23 @@ public void setJwkSetUri(String jwkSetUri) { this.jwkSetUri = jwkSetUri; } + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.security.oauth2.resourceserver.jwt.jws-algorithms") public String getJwsAlgorithm() { - return this.jwsAlgorithm; + return this.jwsAlgorithms.isEmpty() ? null : this.jwsAlgorithms.get(0); } + @Deprecated public void setJwsAlgorithm(String jwsAlgorithm) { - this.jwsAlgorithm = jwsAlgorithm; + this.jwsAlgorithms = new ArrayList<>(Arrays.asList(jwsAlgorithm)); + } + + public List getJwsAlgorithms() { + return this.jwsAlgorithms; + } + + public void setJwsAlgorithms(List jwsAlgortithms) { + this.jwsAlgorithms = jwsAlgortithms; } public String getIssuerUri() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration.java index 2d770a7fe8f2..715aa69dd207 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration.java @@ -23,6 +23,7 @@ import java.util.Base64; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Supplier; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -78,8 +79,7 @@ static class JwtConfiguration { @ConditionalOnProperty(name = "spring.security.oauth2.resourceserver.jwt.jwk-set-uri") ReactiveJwtDecoder jwtDecoder() { NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = NimbusReactiveJwtDecoder - .withJwkSetUri(this.properties.getJwkSetUri()) - .jwsAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm())).build(); + .withJwkSetUri(this.properties.getJwkSetUri()).jwsAlgorithms(this::jwsAlgorithms).build(); String issuerUri = this.properties.getIssuerUri(); Supplier> defaultValidator = (issuerUri != null) ? () -> JwtValidators.createDefaultWithIssuer(issuerUri) : JwtValidators::createDefault; @@ -87,6 +87,12 @@ ReactiveJwtDecoder jwtDecoder() { return nimbusReactiveJwtDecoder; } + private void jwsAlgorithms(Set signatureAlgorithms) { + for (String algorithm : this.properties.getJwsAlgorithms()) { + signatureAlgorithms.add(SignatureAlgorithm.from(algorithm)); + } + } + private OAuth2TokenValidator getValidators(Supplier> defaultValidator) { OAuth2TokenValidator defaultValidators = defaultValidator.get(); List audiences = this.properties.getAudiences(); @@ -106,7 +112,7 @@ NimbusReactiveJwtDecoder jwtDecoderByPublicKeyValue() throws Exception { RSAPublicKey publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA") .generatePublic(new X509EncodedKeySpec(getKeySpec(this.properties.readPublicKey()))); NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withPublicKey(publicKey) - .signatureAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm())).build(); + .signatureAlgorithm(SignatureAlgorithm.from(exactlyOneAlgorithm())).build(); jwtDecoder.setJwtValidator(getValidators(JwtValidators::createDefault)); return jwtDecoder; } @@ -116,6 +122,17 @@ private byte[] getKeySpec(String keyValue) { return Base64.getMimeDecoder().decode(keyValue); } + private String exactlyOneAlgorithm() { + List algorithms = this.properties.getJwsAlgorithms(); + int count = (algorithms != null) ? algorithms.size() : 0; + if (count != 1) { + throw new IllegalStateException( + "Creating a JWT decoder using a public key requires exactly one JWS algorithm but " + count + + " were configured"); + } + return algorithms.get(0); + } + @Bean @Conditional(IssuerUriCondition.class) SupplierReactiveJwtDecoder jwtDecoderByIssuerUri() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java index 14d37c2bee77..479ace9b4321 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java @@ -23,6 +23,7 @@ import java.util.Base64; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Supplier; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -78,7 +79,7 @@ static class JwtDecoderConfiguration { @ConditionalOnProperty(name = "spring.security.oauth2.resourceserver.jwt.jwk-set-uri") JwtDecoder jwtDecoderByJwkKeySetUri() { NimbusJwtDecoder nimbusJwtDecoder = NimbusJwtDecoder.withJwkSetUri(this.properties.getJwkSetUri()) - .jwsAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm())).build(); + .jwsAlgorithms(this::jwsAlgorithms).build(); String issuerUri = this.properties.getIssuerUri(); Supplier> defaultValidator = (issuerUri != null) ? () -> JwtValidators.createDefaultWithIssuer(issuerUri) : JwtValidators::createDefault; @@ -86,6 +87,12 @@ JwtDecoder jwtDecoderByJwkKeySetUri() { return nimbusJwtDecoder; } + private void jwsAlgorithms(Set signatureAlgorithms) { + for (String algorithm : this.properties.getJwsAlgorithms()) { + signatureAlgorithms.add(SignatureAlgorithm.from(algorithm)); + } + } + private OAuth2TokenValidator getValidators(Supplier> defaultValidator) { OAuth2TokenValidator defaultValidators = defaultValidator.get(); List audiences = this.properties.getAudiences(); @@ -105,7 +112,7 @@ JwtDecoder jwtDecoderByPublicKeyValue() throws Exception { RSAPublicKey publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA") .generatePublic(new X509EncodedKeySpec(getKeySpec(this.properties.readPublicKey()))); NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withPublicKey(publicKey) - .signatureAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm())).build(); + .signatureAlgorithm(SignatureAlgorithm.from(exactlyOneAlgorithm())).build(); jwtDecoder.setJwtValidator(getValidators(JwtValidators::createDefault)); return jwtDecoder; } @@ -115,6 +122,17 @@ private byte[] getKeySpec(String keyValue) { return Base64.getMimeDecoder().decode(keyValue); } + private String exactlyOneAlgorithm() { + List algorithms = this.properties.getJwsAlgorithms(); + int count = (algorithms != null) ? algorithms.size() : 0; + if (count != 1) { + throw new IllegalStateException( + "Creating a JWT decoder using a public key requires exactly one JWS algorithm but " + count + + " were configured"); + } + return algorithms.get(0); + } + @Bean @Conditional(IssuerUriCondition.class) SupplierJwtDecoder jwtDecoderByIssuerUri() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 15636a04d9bd..7003a59412ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -2058,6 +2058,11 @@ "name": "spring.security.filter.order", "defaultValue": -100 }, + { + "name": "spring.security.oauth2.resourceserver.jwt.jws-algorithm", + "description": "JSON Web Algorithm used for verifying the digital signatures.", + "defaultValue": "RS256" + }, { "name": "spring.session.hazelcast.flush-mode", "defaultValue": "on-save" 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 e0f51ce2ee13..cb339cbd7ddf 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 @@ -32,6 +32,7 @@ import com.nimbusds.jose.JWSAlgorithm; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -114,6 +115,7 @@ void autoConfigurationShouldConfigureResourceServer() { @SuppressWarnings("unchecked") @Test + @Deprecated void autoConfigurationUsingJwkSetUriShouldConfigureResourceServerUsingJwsAlgorithm() { this.contextRunner .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", @@ -126,6 +128,33 @@ void autoConfigurationUsingJwkSetUriShouldConfigureResourceServerUsingJwsAlgorit } @Test + void autoConfigurationUsingJwkSetUriShouldConfigureResourceServerUsingSingleJwsAlgorithm() { + this.contextRunner + .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS512") + .run((context) -> { + NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = context.getBean(NimbusReactiveJwtDecoder.class); + assertThat(nimbusReactiveJwtDecoder).extracting("jwtProcessor.arg$2.arg$1.jwsAlgs") + .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) + .containsExactlyInAnyOrder(JWSAlgorithm.RS512); + }); + } + + @Test + void autoConfigurationUsingJwkSetUriShouldConfigureResourceServerUsingMultipleJwsAlgorithms() { + this.contextRunner + .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS256, RS384, RS512") + .run((context) -> { + NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = context.getBean(NimbusReactiveJwtDecoder.class); + assertThat(nimbusReactiveJwtDecoder).extracting("jwtProcessor.arg$2.arg$1.jwsAlgs") + .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) + .containsExactlyInAnyOrder(JWSAlgorithm.RS256, JWSAlgorithm.RS384, JWSAlgorithm.RS512); + }); + } + + @Test + @Deprecated void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingJwsAlgorithm() { this.contextRunner.withPropertyValues( "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", @@ -136,6 +165,29 @@ void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingJwsAl }); } + @Test + void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingSingleJwsAlgorithm() { + this.contextRunner.withPropertyValues( + "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS384").run((context) -> { + NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = context.getBean(NimbusReactiveJwtDecoder.class); + assertThat(nimbusReactiveJwtDecoder).extracting("jwtProcessor.arg$1.jwsKeySelector.expectedJWSAlg") + .isEqualTo(JWSAlgorithm.RS384); + }); + } + + @Test + void autoConfigurationUsingPublicKeyValueWithMultipleJwsAlgorithmsShouldFail() { + this.contextRunner.withPropertyValues( + "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RSA256,RS384").run((context) -> { + assertThat(context).hasFailed(); + assertThat(context.getStartupFailure()).hasRootCauseMessage( + "Creating a JWT decoder using a public key requires exactly one JWS algorithm but 2 were " + + "configured"); + }); + } + @Test @SuppressWarnings("unchecked") void autoConfigurationShouldConfigureResourceServerUsingOidcIssuerUri() throws IOException { 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 ebce6261c449..bb804edf6ce6 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 @@ -33,6 +33,7 @@ import com.nimbusds.jose.JWSAlgorithm; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -55,6 +56,7 @@ import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.security.oauth2.jwt.JwtIssuerValidator; import org.springframework.security.oauth2.jwt.JwtTimestampValidator; +import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; import org.springframework.security.oauth2.jwt.SupplierJwtDecoder; import org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken; import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider; @@ -120,6 +122,7 @@ void autoConfigurationShouldMatchDefaultJwsAlgorithm() { } @Test + @Deprecated void autoConfigurationShouldConfigureResourceServerWithJwsAlgorithm() { this.contextRunner .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", @@ -134,6 +137,73 @@ void autoConfigurationShouldConfigureResourceServerWithJwsAlgorithm() { }); } + @Test + void autoConfigurationShouldConfigureResourceServerWithSingleJwsAlgorithm() { + this.contextRunner + .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS384") + .run((context) -> { + JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); + Object processor = ReflectionTestUtils.getField(jwtDecoder, "jwtProcessor"); + Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); + assertThat(keySelector).extracting("jwsAlgs") + .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) + .containsExactlyInAnyOrder(JWSAlgorithm.RS384); + assertThat(getBearerTokenFilter(context)).isNotNull(); + }); + } + + @Test + void autoConfigurationShouldConfigureResourceServerWithMultipleJwsAlgorithms() { + this.contextRunner + .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS256, RS384, RS512") + .run((context) -> { + JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); + Object processor = ReflectionTestUtils.getField(jwtDecoder, "jwtProcessor"); + Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); + assertThat(keySelector).extracting("jwsAlgs") + .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) + .containsExactlyInAnyOrder(JWSAlgorithm.RS256, JWSAlgorithm.RS384, JWSAlgorithm.RS512); + assertThat(getBearerTokenFilter(context)).isNotNull(); + }); + } + + @Test + @Deprecated + void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingJwsAlgorithm() { + this.contextRunner.withPropertyValues( + "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", + "spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS384").run((context) -> { + NimbusJwtDecoder nimbusJwtDecoder = context.getBean(NimbusJwtDecoder.class); + assertThat(nimbusJwtDecoder).extracting("jwtProcessor.jwsKeySelector.expectedJWSAlg") + .isEqualTo(JWSAlgorithm.RS384); + }); + } + + @Test + void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingSingleJwsAlgorithm() { + this.contextRunner.withPropertyValues( + "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS384").run((context) -> { + NimbusJwtDecoder nimbusJwtDecoder = context.getBean(NimbusJwtDecoder.class); + assertThat(nimbusJwtDecoder).extracting("jwtProcessor.jwsKeySelector.expectedJWSAlg") + .isEqualTo(JWSAlgorithm.RS384); + }); + } + + @Test + void autoConfigurationUsingPublicKeyValueWithMultipleJwsAlgorithmsShouldFail() { + this.contextRunner.withPropertyValues( + "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RSA256,RS384").run((context) -> { + assertThat(context).hasFailed(); + assertThat(context.getStartupFailure()).hasRootCauseMessage( + "Creating a JWT decoder using a public key requires exactly one JWS algorithm but 2 were " + + "configured"); + }); + } + @Test @SuppressWarnings("unchecked") void autoConfigurationShouldConfigureResourceServerUsingOidcIssuerUri() throws Exception { From 89bef738467a8fd22d87c76f0740ef55ca0b8771 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 16 Jun 2022 15:39:04 +0100 Subject: [PATCH 089/161] Polish --- .../servlet/OAuth2ResourceServerAutoConfigurationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bb804edf6ce6..a139c1cd942b 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 @@ -302,7 +302,7 @@ void autoConfigurationShouldFailIfAlgorithmIsInvalid() { this.contextRunner .withPropertyValues( "spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location", - "spring.security.oauth2.resourceserver.jwt.jws-algorithm=NOT_VALID") + "spring.security.oauth2.resourceserver.jwt.jws-algorithms=NOT_VALID") .run((context) -> assertThat(context).hasFailed().getFailure() .hasMessageContaining("signatureAlgorithm cannot be null")); } From 252cf9433252b08d8af6dc2457dea57b99658d6b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 16 Jun 2022 17:32:40 +0100 Subject: [PATCH 090/161] Fix requiresUnpack following Bouncy Castle upgrade See gh-31400 --- .../spring-boot-loader-tests-signed-jar-unpack-app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle index 84a7c507ed03..88c4a0e3d877 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/spring-boot-loader-tests-signed-jar-unpack-app/build.gradle @@ -18,5 +18,5 @@ dependencies { } bootJar { - requiresUnpack '**/bcprov-jdk15on-*.jar' + requiresUnpack '**/bcprov-jdk18on-*.jar' } \ No newline at end of file From ae6311ddda58ff557894ee2987edc5b487efbea6 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 16 Jun 2022 15:31:36 -0700 Subject: [PATCH 091/161] Prevent Logback from accidentally being used in Log4J2LoggingSystemTests Update `Log4J2LoggingSystemTests` to exclude Logback and include 'log4j-slf4j-impl'. The `ModifiedClassPathClassLoader` has also been updated so that it no longer automatically excludes `log4j` artifacts, instead we now use `@ClassPathExclusions` on the relevant tests. Fixes gh-19365 --- ...csWithLog4jLoggerContextAutoConfigurationTests.java | 4 +++- ...ricsAutoConfigurationWithLog4j2AndLogbackTests.java | 4 +++- .../classpath/ModifiedClassPathClassLoader.java | 9 +++------ .../LogbackAndLog4J2ExcludedLoggingSystemTests.java | 5 ++--- .../boot/logging/log4j2/Log4J2LoggingSystemTests.java | 10 +++++++--- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests.java index 85695565e9c2..a38764b8117f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -23,6 +23,7 @@ import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.boot.testsupport.classpath.ClassPathOverrides; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,6 +35,7 @@ * * @author Andy Wilkinson */ +@ClassPathExclusions("log4j-to-slf4j-*.jar") @ClassPathOverrides("org.apache.logging.log4j:log4j-core:2.11.1") class Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationWithLog4j2AndLogbackTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationWithLog4j2AndLogbackTests.java index 7cb08ce22fef..4466d8278c41 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationWithLog4j2AndLogbackTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationWithLog4j2AndLogbackTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -21,6 +21,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.boot.testsupport.classpath.ClassPathOverrides; import static org.assertj.core.api.Assertions.assertThat; @@ -31,6 +32,7 @@ * * @author Andy Wilkinson */ +@ClassPathExclusions("log4j-to-slf4j-*.jar") @ClassPathOverrides({ "org.apache.logging.log4j:log4j-core:2.9.0", "org.apache.logging.log4j:log4j-slf4j-impl:2.9.0" }) class MetricsAutoConfigurationWithLog4j2AndLogbackTests { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java index adae5409fb75..528e32c59203 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.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. @@ -242,11 +242,8 @@ private static final class ClassPathEntryFilter { private final AntPathMatcher matcher = new AntPathMatcher(); private ClassPathEntryFilter(MergedAnnotation annotation) { - this.exclusions = new ArrayList<>(); - this.exclusions.add("log4j-*.jar"); - if (annotation.isPresent()) { - this.exclusions.addAll(Arrays.asList(annotation.getStringArray(MergedAnnotation.VALUE))); - } + this.exclusions = annotation.getValue(MergedAnnotation.VALUE, String[].class).map(Arrays::asList) + .orElse(Collections.emptyList()); } private boolean isExcluded(URL url) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogbackAndLog4J2ExcludedLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogbackAndLog4J2ExcludedLoggingSystemTests.java index 550194cada42..d8731d71a2fb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogbackAndLog4J2ExcludedLoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogbackAndLog4J2ExcludedLoggingSystemTests.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,8 +28,7 @@ * * @author Andy Wilkinson */ -// Log4j2 is implicitly excluded due to LOG4J-2030 -@ClassPathExclusions("logback-*.jar") +@ClassPathExclusions({ "log4j-*.jar", "logback-*.jar" }) class LogbackAndLog4J2ExcludedLoggingSystemTests { @Test 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 1da829f82961..1a040a6bbdf0 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 @@ -40,7 +40,6 @@ import org.apache.logging.log4j.util.PropertiesUtil; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -50,6 +49,8 @@ import org.springframework.boot.logging.LoggingInitializationContext; import org.springframework.boot.logging.LoggingSystem; import org.springframework.boot.logging.LoggingSystemProperties; +import org.springframework.boot.testsupport.classpath.ClassPathExclusions; +import org.springframework.boot.testsupport.classpath.ClassPathOverrides; import org.springframework.boot.testsupport.system.CapturedOutput; import org.springframework.boot.testsupport.system.OutputCaptureExtension; import org.springframework.mock.env.MockEnvironment; @@ -74,6 +75,8 @@ * @author Madhura Bhave */ @ExtendWith(OutputCaptureExtension.class) +@ClassPathExclusions("logback-*.jar") +@ClassPathOverrides("org.apache.logging.log4j:log4j-slf4j-impl:2.17.2") class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { private final TestLog4J2LoggingSystem loggingSystem = new TestLog4J2LoggingSystem(); @@ -247,11 +250,12 @@ void setLevelOfUnconfiguredLoggerDoesNotAffectRootConfiguration(CapturedOutput o } @Test - @Disabled("Uses Logback unintentionally") void loggingThatUsesJulIsCaptured(CapturedOutput output) { + String name = getClass().getName(); this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(this.initializationContext, null, null); - java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(getClass().getName()); + this.loggingSystem.setLogLevel(name, LogLevel.TRACE); + java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(name); julLogger.setLevel(java.util.logging.Level.INFO); julLogger.severe("Hello world"); assertThat(output).contains("Hello world"); From ae1b47c24531deca385c1ac59c794d6752ed9591 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:12 +0200 Subject: [PATCH 092/161] Upgrade to AppEngine SDK 1.9.97 Closes gh-31410 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index c47608adc0c3..f95e86dc114a 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -63,7 +63,7 @@ bom { ] } } - library("AppEngine SDK", "1.9.96") { + library("AppEngine SDK", "1.9.97") { group("com.google.appengine") { modules = [ "appengine-api-1.0-sdk" From 623a48fb0367c40c95f1ad0ff5e4cd49c562adb4 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:14 +0200 Subject: [PATCH 093/161] Upgrade to Groovy 3.0.11 Closes gh-31411 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index f95e86dc114a..d032b7c0054d 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -377,7 +377,7 @@ bom { ] } } - library("Groovy", "3.0.10") { + library("Groovy", "3.0.11") { group("org.codehaus.groovy") { imports = [ "groovy-bom" From 78d0db7ff06983283ea906efb9748bf877a76a0a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:16 +0200 Subject: [PATCH 094/161] Upgrade to Infinispan 12.1.12.Final Closes gh-31412 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d032b7c0054d..0e660e5cdbd2 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -536,7 +536,7 @@ bom { ] } } - library("Infinispan", "12.1.11.Final") { + library("Infinispan", "12.1.12.Final") { group("org.infinispan") { imports = [ "infinispan-bom" From 3b20c67f029d005d92e2de29fb245f510916e1cb Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:19 +0200 Subject: [PATCH 095/161] Upgrade to jOOQ 3.14.16 Closes gh-31413 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0e660e5cdbd2..25fd0f391b00 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -952,7 +952,7 @@ bom { ] } } - library("jOOQ", "3.14.15") { + library("jOOQ", "3.14.16") { prohibit("[3.15.0,)") { because "it requires Java 11" } From 71e5b909489356634eaa3e703e56267e686efcd0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:21 +0200 Subject: [PATCH 096/161] Upgrade to Neo4j Java Driver 4.4.6 Closes gh-31414 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 25fd0f391b00..0592392f560e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1312,7 +1312,7 @@ bom { ] } } - library("Neo4j Java Driver", "4.4.5") { + library("Neo4j Java Driver", "4.4.6") { group("org.neo4j.driver") { modules = [ "neo4j-java-driver" From 9076e38f06a00fb805a47c2669bee0e35147eb26 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:23 +0200 Subject: [PATCH 097/161] Upgrade to Netty 4.1.78.Final Closes gh-31415 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0592392f560e..881b47813061 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1319,7 +1319,7 @@ bom { ] } } - library("Netty", "4.1.77.Final") { + library("Netty", "4.1.78.Final") { group("io.netty") { imports = [ "netty-bom" From 854578c936b231510bdd8729884350e0d82ebf3a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:25 +0200 Subject: [PATCH 098/161] Upgrade to Netty tcNative 2.0.53.Final Closes gh-31416 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 881b47813061..0d6cf466b17b 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1326,7 +1326,7 @@ bom { ] } } - library("Netty tcNative", "2.0.52.Final") { + library("Netty tcNative", "2.0.53.Final") { group("io.netty") { modules = [ "netty-tcnative", From 898cf7665adbf9d137beb5316ed2b2dd02472a3e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:28 +0200 Subject: [PATCH 099/161] Upgrade to Postgresql 42.3.6 Closes gh-31417 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0d6cf466b17b..198a34cab613 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1397,7 +1397,7 @@ bom { ] } } - library("Postgresql", "42.3.5") { + library("Postgresql", "42.3.6") { group("org.postgresql") { modules = [ "postgresql" From 0edf12c07c5105662e74bc7cd9ea52f057f9337e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:30 +0200 Subject: [PATCH 100/161] Upgrade to Reactive Streams 1.0.4 Closes gh-31418 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 198a34cab613..252e93a0df80 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1450,7 +1450,7 @@ bom { ] } } - library("Reactive Streams", "1.0.3") { + library("Reactive Streams", "1.0.4") { group("org.reactivestreams") { modules = [ "reactive-streams" From 42eaa4d4f65ee5e966a0b94e692b58c4442daf6d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:32 +0200 Subject: [PATCH 101/161] Upgrade to Tomcat 9.0.64 Closes gh-31419 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0c6dd8960c1d..f95fae9a7c53 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,6 @@ org.gradle.parallel=true org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 kotlinVersion=1.6.21 -tomcatVersion=9.0.63 +tomcatVersion=9.0.64 kotlin.stdlib.default.dependency=false From 8548f1a1cbc096be2e1f5005400d5e23f24ec174 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:30:34 +0200 Subject: [PATCH 102/161] Upgrade to Undertow 2.2.18.Final Closes gh-31420 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 252e93a0df80..cd0ff12bad09 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1865,7 +1865,7 @@ bom { ] } } - library("Undertow", "2.2.17.Final") { + library("Undertow", "2.2.18.Final") { group("io.undertow") { modules = [ "undertow-core", From d82c6dc2913a401456cec3301814307cefb2ec05 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:07 +0200 Subject: [PATCH 103/161] Upgrade to AppEngine SDK 1.9.97 Closes gh-31421 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 5331ec05feab..b56b30d21bb6 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -66,7 +66,7 @@ bom { ] } } - library("AppEngine SDK", "1.9.96") { + library("AppEngine SDK", "1.9.97") { group("com.google.appengine") { modules = [ "appengine-api-1.0-sdk" From 9590a9914ac9f19b83db57d34e95ff7a9f9073e9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:10 +0200 Subject: [PATCH 104/161] Upgrade to Couchbase Client 3.3.1 Closes gh-31422 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index b56b30d21bb6..988ea05d4db0 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -241,7 +241,7 @@ bom { ] } } - library("Couchbase Client", "3.3.0") { + library("Couchbase Client", "3.3.1") { group("com.couchbase.client") { modules = [ "java-client" From 54e4ff8e8189b88494ba9b082b2356d224f91177 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:12 +0200 Subject: [PATCH 105/161] Upgrade to Elasticsearch 7.17.4 Closes gh-31423 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 988ea05d4db0..5ae443790204 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -296,7 +296,7 @@ bom { ] } } - library("Elasticsearch", "7.17.3") { + library("Elasticsearch", "7.17.4") { group("org.elasticsearch") { modules = [ "elasticsearch" From e60a235194fd696547abc6c6035585ff0130f3a0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:14 +0200 Subject: [PATCH 106/161] Upgrade to Embedded Mongo 3.4.6 Closes gh-31424 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 5ae443790204..d9ea1386bca5 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -327,7 +327,7 @@ bom { ] } } - library("Embedded Mongo", "3.4.5") { + library("Embedded Mongo", "3.4.6") { group("de.flapdoodle.embed") { modules = [ "de.flapdoodle.embed.mongo" From 4d03653b74bb7d0b819c9a8c1494a9459ba7d437 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:16 +0200 Subject: [PATCH 107/161] Upgrade to Flyway 8.5.13 Closes gh-31425 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d9ea1386bca5..ab23eeb1b49f 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -334,7 +334,7 @@ bom { ] } } - library("Flyway", "8.5.11") { + library("Flyway", "8.5.13") { group("org.flywaydb") { modules = [ "flyway-core", From cd2a8a91dadd837b1108579737ba68b7c020d904 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:19 +0200 Subject: [PATCH 108/161] Upgrade to Groovy 3.0.11 Closes gh-31426 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index ab23eeb1b49f..656ff8721b50 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -408,7 +408,7 @@ bom { ] } } - library("Groovy", "3.0.10") { + library("Groovy", "3.0.11") { group("org.codehaus.groovy") { imports = [ "groovy-bom" From 670876b52dd7f35f9c96cf137622aa09cef020f5 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:22 +0200 Subject: [PATCH 109/161] Upgrade to H2 2.1.214 Closes gh-31427 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 656ff8721b50..6399255f665e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -422,7 +422,7 @@ bom { ] } } - library("H2", "2.1.212") { + library("H2", "2.1.214") { group("com.h2database") { modules = [ "h2" From 26b64e771352fb8b3f8bce831c45553ce36040cc Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:24 +0200 Subject: [PATCH 110/161] Upgrade to Hazelcast 5.1.2 Closes gh-31428 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 6399255f665e..7b2fc6be31a2 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -438,7 +438,7 @@ bom { ] } } - library("Hazelcast", "5.1.1") { + library("Hazelcast", "5.1.2") { group("com.hazelcast") { modules = [ "hazelcast", From dbf3677c0a0ac4a8b63e5380a7124fc52305caa5 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:26 +0200 Subject: [PATCH 111/161] Upgrade to jOOQ 3.14.16 Closes gh-31429 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 7b2fc6be31a2..8d2139a0001e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -983,7 +983,7 @@ bom { ] } } - library("jOOQ", "3.14.15") { + library("jOOQ", "3.14.16") { prohibit("[3.15.0,)") { because "it requires Java 11" } From 338d8d997b376e5e2660877ef1a8c4cc45e7b614 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:29 +0200 Subject: [PATCH 112/161] Upgrade to Kotlin Coroutines 1.6.2 Closes gh-31430 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 8d2139a0001e..fa5e70554d4f 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1100,7 +1100,7 @@ bom { ] } } - library("Kotlin Coroutines", "1.6.1") { + library("Kotlin Coroutines", "1.6.2") { group("org.jetbrains.kotlinx") { imports = [ "kotlinx-coroutines-bom" From c93d3201ff2f06e246966973dd6a9ea63af35266 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:31 +0200 Subject: [PATCH 113/161] Upgrade to MariaDB 3.0.5 Closes gh-31431 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index fa5e70554d4f..38b7ef3c3ac3 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1148,7 +1148,7 @@ bom { ] } } - library("MariaDB", "3.0.4") { + library("MariaDB", "3.0.5") { group("org.mariadb.jdbc") { modules = [ "mariadb-java-client" From 8e911affadde4e2ce890db3589fae4de1d901244 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:33 +0200 Subject: [PATCH 114/161] Upgrade to MongoDB 4.6.1 Closes gh-31432 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 38b7ef3c3ac3..d1ed10676e9f 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1300,7 +1300,7 @@ bom { ] } } - library("MongoDB", "4.6.0") { + library("MongoDB", "4.6.1") { group("org.mongodb") { modules = [ "bson", From e43e9c3c404fb86cf67eaf1a4f03fddfb2f7a2a3 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:35 +0200 Subject: [PATCH 115/161] Upgrade to Neo4j Java Driver 4.4.6 Closes gh-31433 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d1ed10676e9f..30af324a8a4e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1334,7 +1334,7 @@ bom { ] } } - library("Neo4j Java Driver", "4.4.5") { + library("Neo4j Java Driver", "4.4.6") { group("org.neo4j.driver") { modules = [ "neo4j-java-driver" From 548e8728e436dfaf523e8472c1844fd8cd7c5f10 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:38 +0200 Subject: [PATCH 116/161] Upgrade to Netty 4.1.78.Final Closes gh-31434 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 30af324a8a4e..c311b9268d56 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1341,7 +1341,7 @@ bom { ] } } - library("Netty", "4.1.77.Final") { + library("Netty", "4.1.78.Final") { group("io.netty") { imports = [ "netty-bom" From 91d9d484460b394f9a2befddc3d475d0905d5f6e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:40 +0200 Subject: [PATCH 117/161] Upgrade to Postgresql 42.3.6 Closes gh-31435 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index c311b9268d56..1ea9ec961a01 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1372,7 +1372,7 @@ bom { ] } } - library("Postgresql", "42.3.5") { + library("Postgresql", "42.3.6") { group("org.postgresql") { modules = [ "postgresql" From 4f95fdea82b33f2324758a6ee233d603d3aa6a4b Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:42 +0200 Subject: [PATCH 118/161] Upgrade to Reactive Streams 1.0.4 Closes gh-31436 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 1ea9ec961a01..9efdc97ced0e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1425,7 +1425,7 @@ bom { ] } } - library("Reactive Streams", "1.0.3") { + library("Reactive Streams", "1.0.4") { group("org.reactivestreams") { modules = [ "reactive-streams" From b57e3aa7e90d163ff4373668edef5bd9ec19c237 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:45 +0200 Subject: [PATCH 119/161] Upgrade to Tomcat 9.0.64 Closes gh-31437 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ee93bc516b5e..bdc15267753e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,6 @@ org.gradle.parallel=true org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 kotlinVersion=1.6.21 -tomcatVersion=9.0.63 +tomcatVersion=9.0.64 kotlin.stdlib.default.dependency=false From c61fab27773028d8e2090957bbe0f7fd3bff1410 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 10:59:47 +0200 Subject: [PATCH 120/161] Upgrade to Undertow 2.2.18.Final Closes gh-31438 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 9efdc97ced0e..2e8f49f93f4a 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1888,7 +1888,7 @@ bom { ] } } - library("Undertow", "2.2.17.Final") { + library("Undertow", "2.2.18.Final") { group("io.undertow") { modules = [ "undertow-core", From 3366e4de251874040b9caf5badc22a69de51b4df Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 17 Jun 2022 11:00:10 +0200 Subject: [PATCH 121/161] Upgrade to Spring LDAP 2.4.1 Closes gh-31373 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 2e8f49f93f4a..ac926e69bb92 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1736,7 +1736,7 @@ bom { ] } } - library("Spring LDAP", "2.4.1-SNAPSHOT") { + library("Spring LDAP", "2.4.1") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From 2376d7ced483577d244e703f1e84fc41b2d9b80d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 17 Jun 2022 14:27:05 +0100 Subject: [PATCH 122/161] Remind ourselves to update .sdkmanrc when upgrading Java Closes gh-31445 --- ci/scripts/detect-jdk-updates.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/detect-jdk-updates.sh b/ci/scripts/detect-jdk-updates.sh index 70955482bbd7..cf8bb019d935 100755 --- a/ci/scripts/detect-jdk-updates.sh +++ b/ci/scripts/detect-jdk-updates.sh @@ -10,7 +10,7 @@ trap 'report_error $? $LINENO' ERR case "$JDK_VERSION" in java8) BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=8" - ISSUE_TITLE="Upgrade Java 8 version in CI image" + ISSUE_TITLE="Upgrade Java 8 version in CI image and .sdkmanrc" ;; java11) BASE_URL="https://api.bell-sw.com/v1/liberica/releases?version-feature=11" From 0549b7591f3500bbca190c501e94f2ae8bc78dd4 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 17 Jun 2022 14:32:26 +0100 Subject: [PATCH 123/161] Align .sdkmanrc with CI's Java 8 version See gh-31291 --- .sdkmanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sdkmanrc b/.sdkmanrc index 51f59b27450b..e1f4b3591303 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,3 +1,3 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=8.0.332-librca +java=8.0.333-librca From 11a07a9d1e12a2fda4266c3f4f366b052a3cc27d Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sun, 19 Jun 2022 00:08:36 +0900 Subject: [PATCH 124/161] Polish OAuth2ResourceServerAutoConfigurationTests See gh-31453 --- ...2ResourceServerAutoConfigurationTests.java | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) 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 a139c1cd942b..efc7724bf560 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 @@ -114,10 +114,9 @@ void autoConfigurationShouldMatchDefaultJwsAlgorithm() { .withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com") .run((context) -> { JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - Object processor = ReflectionTestUtils.getField(jwtDecoder, "jwtProcessor"); - Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); - assertThat(keySelector).hasFieldOrPropertyWithValue("jwsAlgs", - Collections.singleton(JWSAlgorithm.RS256)); + assertThat(jwtDecoder).extracting("jwtProcessor.jwsKeySelector.jwsAlgs") + .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) + .containsExactlyInAnyOrder(JWSAlgorithm.RS256); }); } @@ -144,9 +143,7 @@ void autoConfigurationShouldConfigureResourceServerWithSingleJwsAlgorithm() { "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS384") .run((context) -> { JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - Object processor = ReflectionTestUtils.getField(jwtDecoder, "jwtProcessor"); - Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); - assertThat(keySelector).extracting("jwsAlgs") + assertThat(jwtDecoder).extracting("jwtProcessor.jwsKeySelector.jwsAlgs") .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) .containsExactlyInAnyOrder(JWSAlgorithm.RS384); assertThat(getBearerTokenFilter(context)).isNotNull(); @@ -160,9 +157,7 @@ void autoConfigurationShouldConfigureResourceServerWithMultipleJwsAlgorithms() { "spring.security.oauth2.resourceserver.jwt.jws-algorithms=RS256, RS384, RS512") .run((context) -> { JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - Object processor = ReflectionTestUtils.getField(jwtDecoder, "jwtProcessor"); - Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); - assertThat(keySelector).extracting("jwsAlgs") + assertThat(jwtDecoder).extracting("jwtProcessor.jwsKeySelector.jwsAlgs") .asInstanceOf(InstanceOfAssertFactories.collection(JWSAlgorithm.class)) .containsExactlyInAnyOrder(JWSAlgorithm.RS256, JWSAlgorithm.RS384, JWSAlgorithm.RS512); assertThat(getBearerTokenFilter(context)).isNotNull(); @@ -472,11 +467,9 @@ void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri() .run((context) -> { assertThat(context).hasSingleBean(JwtDecoder.class); JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils - .getField(jwtDecoder, "jwtValidator"); - Collection> tokenValidators = (Collection>) ReflectionTestUtils - .getField(jwtValidator, "tokenValidators"); - assertThat(tokenValidators).hasAtLeastOneElementOfType(JwtIssuerValidator.class); + assertThat(jwtDecoder).extracting("jwtValidator.tokenValidators") + .asInstanceOf(InstanceOfAssertFactories.collection(OAuth2TokenValidator.class)) + .hasAtLeastOneElementOfType(JwtIssuerValidator.class); }); } @@ -494,13 +487,11 @@ void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfProper .run((context) -> { assertThat(context).hasSingleBean(JwtDecoder.class); JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); - DelegatingOAuth2TokenValidator jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils - .getField(jwtDecoder, "jwtValidator"); - Collection> tokenValidators = (Collection>) ReflectionTestUtils - .getField(jwtValidator, "tokenValidators"); - assertThat(tokenValidators).hasExactlyElementsOfTypes(JwtTimestampValidator.class); - assertThat(tokenValidators).doesNotHaveAnyElementsOfTypes(JwtClaimValidator.class); - assertThat(tokenValidators).doesNotHaveAnyElementsOfTypes(JwtIssuerValidator.class); + assertThat(jwtDecoder).extracting("jwtValidator.tokenValidators") + .asInstanceOf(InstanceOfAssertFactories.collection(OAuth2TokenValidator.class)) + .hasExactlyElementsOfTypes(JwtTimestampValidator.class) + .doesNotHaveAnyElementsOfTypes(JwtClaimValidator.class) + .doesNotHaveAnyElementsOfTypes(JwtIssuerValidator.class); }); } @@ -565,10 +556,10 @@ private void validateDelegates(String issuerUri, Collection delegatingValidator = delegates.stream() .filter((v) -> v instanceof DelegatingOAuth2TokenValidator).findFirst().get(); - Collection> nestedDelegates = (Collection>) ReflectionTestUtils - .getField(delegatingValidator, "tokenValidators"); if (issuerUri != null) { - assertThat(nestedDelegates).hasAtLeastOneElementOfType(JwtIssuerValidator.class); + assertThat(delegatingValidator).extracting("tokenValidators") + .asInstanceOf(InstanceOfAssertFactories.collection(OAuth2TokenValidator.class)) + .hasAtLeastOneElementOfType(JwtIssuerValidator.class); } } From 6685d49faaa541faa3c5b68c81c9445c228ff6fa Mon Sep 17 00:00:00 2001 From: ningenMe Date: Mon, 20 Jun 2022 00:24:46 +0900 Subject: [PATCH 125/161] Harmonize Kotlin example See gh-31458 --- .../springapplication/applicationexit/MyApplication.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt index 8a9af9e30aff..488273cb8509 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt @@ -32,5 +32,5 @@ class MyApplication { } fun main(args: Array) { - SpringApplication.run(MyApplication::class.java, *args) -} \ No newline at end of file + exitProcess(SpringApplication.exit(SpringApplication.run(MyApplication::class.java, *args))) +} From 8b9579eeb7ba0bd52499510159e446ddbdb7b457 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jun 2022 10:33:34 +0200 Subject: [PATCH 126/161] Polish "Harmonize Kotlin example" See gh-31458 --- .../springapplication/applicationexit/MyApplication.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt index 488273cb8509..ad7abfcce8b4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt @@ -21,6 +21,8 @@ import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.Bean +import kotlin.system.exitProcess + @SpringBootApplication class MyApplication { @@ -32,5 +34,6 @@ class MyApplication { } fun main(args: Array) { - exitProcess(SpringApplication.exit(SpringApplication.run(MyApplication::class.java, *args))) + exitProcess(SpringApplication.exit( + SpringApplication.run(MyApplication::class.java, *args))) } From 87ecbc7073ad962c6f7df78cc4363a06223e1ba2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jun 2022 14:19:17 +0200 Subject: [PATCH 127/161] Upgrade to Spring HATEOAS 1.4.4 Closes gh-31464 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index cd0ff12bad09..427d5f1becaf 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1708,7 +1708,7 @@ bom { ] } } - library("Spring HATEOAS", "1.4.3") { + library("Spring HATEOAS", "1.4.4") { group("org.springframework.hateoas") { modules = [ "spring-hateoas" From 46a5e5d9d499ce3c1d5ee5fe1c6c47d61224fcdc Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jun 2022 14:19:53 +0200 Subject: [PATCH 128/161] Upgrade to Spring Data 2021.1.5 Closes gh-31349 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 427d5f1becaf..d5292868c8f9 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1694,7 +1694,7 @@ bom { ] } } - library("Spring Data Bom", "2021.1.5-SNAPSHOT") { + library("Spring Data Bom", "2021.1.5") { group("org.springframework.data") { imports = [ "spring-data-bom" From 4f78f9556d7a27a4c89a66d76eedafc15fb160fc Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jun 2022 14:21:48 +0200 Subject: [PATCH 129/161] Upgrade to Spring HATEOAS 1.5.1 Closes gh-31465 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index ac926e69bb92..d080afb7afb4 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1705,7 +1705,7 @@ bom { ] } } - library("Spring HATEOAS", "1.5.0") { + library("Spring HATEOAS", "1.5.1") { prohibit("[2.0.0-M1,)") { because "it uses Spring Framework 6" } From c04b407913702375891df88077110aed195d1761 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jun 2022 14:22:25 +0200 Subject: [PATCH 130/161] Upgrade to Spring Data 2021.2.1 Closes gh-31374 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d080afb7afb4..3b8c6365d8be 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1677,7 +1677,7 @@ bom { ] } } - library("Spring Data Bom", "2021.2.1-SNAPSHOT") { + library("Spring Data Bom", "2021.2.1") { prohibit("[2022.0.0-M1,)") { because "it uses Spring Framework 6" } From b5d380c1cb024dcb51628266b2877d20b65dc336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 20 Jun 2022 11:24:29 +0200 Subject: [PATCH 131/161] Make SpringApplication Kotlin samples idiomatic See gh-31463 --- .../boot/docs/features/springapplication/MyApplication.kt | 4 ++-- .../springapplication/applicationexit/MyApplication.kt | 7 +++---- .../customizingspringapplication/MyApplication.kt | 8 ++++---- .../springapplication/startuptracking/MyApplication.kt | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt index 2ec0c57dc678..9825f394ee07 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt @@ -16,13 +16,13 @@ package org.springframework.boot.docs.features.springapplication -import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication @SpringBootApplication class MyApplication fun main(args: Array) { - SpringApplication.run(MyApplication::class.java, *args) + runApplication(*args) } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt index ad7abfcce8b4..bd604c0840d6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt @@ -19,6 +19,7 @@ package org.springframework.boot.docs.features.springapplication.applicationexit import org.springframework.boot.ExitCodeGenerator import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication import org.springframework.context.annotation.Bean import kotlin.system.exitProcess @@ -27,13 +28,11 @@ import kotlin.system.exitProcess class MyApplication { @Bean - fun exitCodeGenerator(): ExitCodeGenerator? { - return ExitCodeGenerator { 42 } - } + fun exitCodeGenerator() = ExitCodeGenerator { 42 } } fun main(args: Array) { exitProcess(SpringApplication.exit( - SpringApplication.run(MyApplication::class.java, *args))) + runApplication(*args))) } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt index 4afc48f51155..cba1f1bf241a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt @@ -17,14 +17,14 @@ package org.springframework.boot.docs.features.springapplication.customizingspringapplication import org.springframework.boot.Banner -import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication @SpringBootApplication class MyApplication fun main(args: Array) { - val application = SpringApplication(MyApplication::class.java) - application.setBannerMode(Banner.Mode.OFF) - application.run(*args) + runApplication(*args) { + setBannerMode(Banner.Mode.OFF) + } } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt index 85a2b1c630a8..eaff880c585d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt @@ -16,15 +16,15 @@ package org.springframework.boot.docs.features.springapplication.startuptracking -import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup +import org.springframework.boot.runApplication @SpringBootApplication class MyApplication fun main(args: Array) { - val application = SpringApplication(MyApplication::class.java) - application.applicationStartup = BufferingApplicationStartup(2048) - application.run(*args) + runApplication(*args) { + applicationStartup = BufferingApplicationStartup(2048) + } } \ No newline at end of file From 2a01473ba9af5fa2751c735e3de0d69f8cf99392 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 20 Jun 2022 15:56:31 +0100 Subject: [PATCH 132/161] Upgrade to Gradle Enterprise Conventions 0.0.10 Closes gh-31470 --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index d824aa229fb1..9b935507608c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,7 +23,7 @@ pluginManagement { plugins { id "com.gradle.enterprise" version "3.9" - id "io.spring.ge.conventions" version "0.0.9" + id "io.spring.ge.conventions" version "0.0.10" } rootProject.name="spring-boot-build" From c531bd33e2a276d075f59ca0854b241f9f982576 Mon Sep 17 00:00:00 2001 From: Jerome Prinet Date: Mon, 20 Jun 2022 11:25:21 +0200 Subject: [PATCH 133/161] Upgrade to Gradle Enterprise plugin 3.10.2 See gh-31462 --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 9b935507608c..d7113b6dedca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,7 +22,7 @@ pluginManagement { } plugins { - id "com.gradle.enterprise" version "3.9" + id "com.gradle.enterprise" version "3.10.2" id "io.spring.ge.conventions" version "0.0.10" } From 79580617a6d1e53b7348d52e51163775925de3d8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 20 Jun 2022 20:33:56 +0100 Subject: [PATCH 134/161] Upgrade to Spring Security 5.7.2 Closes gh-31375 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 3b8c6365d8be..cdd997911253 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1771,7 +1771,7 @@ bom { ] } } - library("Spring Security", "5.7.2-SNAPSHOT") { + library("Spring Security", "5.7.2") { prohibit("[6.0.0-M1,)") { because "it uses Spring Framework 6" } From d45e42f2e1d6ad6d3f3a3f7b463e8ac35c66b06c Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 20 Jun 2022 20:46:38 +0100 Subject: [PATCH 135/161] Upgrade to Spring Security 5.6.6 Closes gh-31351 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d5292868c8f9..901178ff8817 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1760,7 +1760,7 @@ bom { ] } } - library("Spring Security", "5.6.6-SNAPSHOT") { + library("Spring Security", "5.6.6") { group("org.springframework.security") { imports = [ "spring-security-bom" From b56b95d4292793db27d11ededc3320f70126d662 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 21 Jun 2022 14:00:55 +0200 Subject: [PATCH 136/161] Add Apache HttpClient WebClient support to documentation --- .../spring-boot-docs/src/docs/asciidoc/io/rest-client.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/rest-client.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/rest-client.adoc index a8cc35099a81..618c8ecf7de3 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/rest-client.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/rest-client.adoc @@ -75,11 +75,11 @@ include::{docs-java}/io/restclient/webclient/MyService.java[] [[io.rest-client.webclient.runtime]] ==== WebClient Runtime Spring Boot will auto-detect which `ClientHttpConnector` to use to drive `WebClient`, depending on the libraries available on the application classpath. -For now, Reactor Netty and Jetty RS client are supported. +For now, Reactor Netty, Jetty RS client and Apache HttpClient are supported. The `spring-boot-starter-webflux` starter depends on `io.projectreactor.netty:reactor-netty` by default, which brings both server and client implementations. If you choose to use Jetty as a reactive server instead, you should add a dependency on the Jetty Reactive HTTP client library, `org.eclipse.jetty:jetty-reactive-httpclient`. -Using the same technology for server and client has it advantages, as it will automatically share HTTP resources between client and server. +Using the same technology for server and client has its advantages, as it will automatically share HTTP resources between client and server. Developers can override the resource configuration for Jetty and Reactor Netty by providing a custom `ReactorResourceFactory` or `JettyResourceFactory` bean - this will be applied to both clients and servers. From 49fd727ef078a7e876cefea392f223d65ff8a4ad Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 21 Jun 2022 16:34:47 +0100 Subject: [PATCH 137/161] Upgrade to Spring AMQP 2.4.6 Closes gh-31348 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 901178ff8817..1f32e526ec11 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1673,7 +1673,7 @@ bom { ] } } - library("Spring AMQP", "2.4.6-SNAPSHOT") { + library("Spring AMQP", "2.4.6") { group("org.springframework.amqp") { modules = [ "spring-amqp", From 390554a84f1f4eceed5f29dee8f591f81b5d5b74 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 21 Jun 2022 16:36:55 +0100 Subject: [PATCH 138/161] Upgrade to Spring AMQP 2.4.6 Closes gh-31376 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index cdd997911253..5946b8cdfa4b 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1650,7 +1650,7 @@ bom { ] } } - library("Spring AMQP", "2.4.6-SNAPSHOT") { + library("Spring AMQP", "2.4.6") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From 4c0a4cb6692253432c3ce59840c13a569cfbe207 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 21 Jun 2022 12:08:03 -0700 Subject: [PATCH 139/161] Polish --- .../boot/autoconfigure/graphql/GraphQlAutoConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java index 4ab4c4444d73..6b19ade6a162 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java @@ -41,6 +41,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.core.log.LogMessage; import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer; import org.springframework.graphql.execution.BatchLoaderRegistry; @@ -111,7 +112,7 @@ private List resolveSchemaResources(ResourcePatternResolver resolver, return Arrays.asList(resolver.getResources(pattern)); } catch (IOException ex) { - logger.debug("Could not resolve schema location: '" + pattern + "'", ex); + logger.debug(LogMessage.format("Could not resolve schema location: '%s'", pattern), ex); return Collections.emptyList(); } } From 7fc9debf2ad8b22a151ca73d79ba5f80228dba99 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 21 Jun 2022 16:06:48 -0700 Subject: [PATCH 140/161] Consider super classes when detecting nested property classes Update `PropertyDescriptor.isParentTheSame` to consider the candidate as well as all super classes. Fixes gh-21626 --- ...figurationMetadataAnnotationProcessor.java | 6 +- .../PropertyDescriptor.java | 17 +++-- .../InheritanceMetadataGenerationTests.java | 61 ++++++++++++++++ ...figurationMetadataAnnotationProcessor.java | 6 +- .../inheritance/BaseProperties.java | 71 +++++++++++++++++++ .../inheritance/ChildProperties.java | 61 ++++++++++++++++ .../inheritance/ChildPropertiesConfig.java | 28 ++++++++ .../inheritance/OverrideChildProperties.java | 36 ++++++++++ .../OverrideChildPropertiesConfig.java | 28 ++++++++ 9 files changed, 304 insertions(+), 10 deletions(-) create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/InheritanceMetadataGenerationTests.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/BaseProperties.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildProperties.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildPropertiesConfig.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildPropertiesConfig.java diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 7cc52dfac797..a1ac4c102db4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.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. @@ -177,7 +177,7 @@ public boolean process(Set annotations, RoundEnvironment } if (roundEnv.processingOver()) { try { - writeMetaData(); + writeMetadata(); } catch (Exception ex) { throw new IllegalStateException("Failed to write metadata", ex); @@ -324,7 +324,7 @@ private String getPrefix(AnnotationMirror annotation) { return null; } - protected ConfigurationMetadata writeMetaData() throws Exception { + protected ConfigurationMetadata writeMetadata() throws Exception { ConfigurationMetadata metadata = this.metadataCollector.getMetadata(); metadata = mergeAdditionalMetadata(metadata); if (!metadata.getItems().isEmpty()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java index 355ac02b1a84..83cc34704225 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -119,7 +119,7 @@ protected boolean isNested(MetadataGenerationEnvironment environment) { if (isCyclePresent(typeElement, getOwnerElement())) { return false; } - return isParentTheSame(typeElement, getOwnerElement()); + return isParentTheSame(environment, typeElement, getOwnerElement()); } ItemMetadata resolveItemMetadata(String prefix, MetadataGenerationEnvironment environment) { @@ -169,11 +169,20 @@ private boolean isCyclePresent(Element returnType, Element element) { return isCyclePresent(returnType, element.getEnclosingElement()); } - private boolean isParentTheSame(Element returnType, TypeElement element) { + private boolean isParentTheSame(MetadataGenerationEnvironment environment, Element returnType, + TypeElement element) { if (returnType == null || element == null) { return false; } - return getTopLevelType(returnType).equals(getTopLevelType(element)); + returnType = getTopLevelType(returnType); + Element candidate = element; + while (candidate != null && candidate instanceof TypeElement) { + if (returnType.equals(getTopLevelType(candidate))) { + return true; + } + candidate = environment.getTypeUtils().asElement(((TypeElement) candidate).getSuperclass()); + } + return false; } private Element getTopLevelType(Element element) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/InheritanceMetadataGenerationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/InheritanceMetadataGenerationTests.java new file mode 100644 index 000000000000..48c72172284a --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/InheritanceMetadataGenerationTests.java @@ -0,0 +1,61 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationprocessor; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; +import org.springframework.boot.configurationprocessor.metadata.Metadata; +import org.springframework.boot.configurationsample.inheritance.ChildProperties; +import org.springframework.boot.configurationsample.inheritance.ChildPropertiesConfig; +import org.springframework.boot.configurationsample.inheritance.OverrideChildProperties; +import org.springframework.boot.configurationsample.inheritance.OverrideChildPropertiesConfig; + +import static org.assertj.core.api.Assertions.assertThat; + +class InheritanceMetadataGenerationTests extends AbstractMetadataGenerationTests { + + @Test + void childProperties() throws Exception { + ConfigurationMetadata metadata = compile(ChildPropertiesConfig.class); + assertThat(metadata).has(Metadata.withGroup("inheritance").fromSource(ChildPropertiesConfig.class)); + assertThat(metadata).has(Metadata.withGroup("inheritance.nest").fromSource(ChildProperties.class)); + assertThat(metadata).has(Metadata.withGroup("inheritance.child-nest").fromSource(ChildProperties.class)); + assertThat(metadata).has(Metadata.withProperty("inheritance.bool-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.int-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.long-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.nest.bool-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.nest.int-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.child-nest.bool-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.child-nest.int-value")); + } + + @Test + void overrideChildProperties() throws Exception { + ConfigurationMetadata metadata = compile(OverrideChildPropertiesConfig.class); + assertThat(metadata).has(Metadata.withGroup("inheritance").fromSource(OverrideChildPropertiesConfig.class)); + assertThat(metadata).has(Metadata.withGroup("inheritance.nest").fromSource(OverrideChildProperties.class)); + assertThat(metadata).has(Metadata.withProperty("inheritance.bool-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.int-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.long-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.nest.bool-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.nest.int-value")); + assertThat(metadata).has(Metadata.withProperty("inheritance.nest.long-value")); + + } + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java index 592a5a5f45c1..59e7f52dd4e6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.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. @@ -127,8 +127,8 @@ protected String nameAnnotation() { } @Override - protected ConfigurationMetadata writeMetaData() throws Exception { - super.writeMetaData(); + protected ConfigurationMetadata writeMetadata() throws Exception { + super.writeMetadata(); try { File metadataFile = new File(this.outputLocation, "META-INF/spring-configuration-metadata.json"); if (metadataFile.isFile()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/BaseProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/BaseProperties.java new file mode 100644 index 000000000000..b83d54e0e1cc --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/BaseProperties.java @@ -0,0 +1,71 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample.inheritance; + +public class BaseProperties { + + private boolean boolValue; + + private int intValue; + + private final Nest nest = new Nest(); + + public boolean isBoolValue() { + return this.boolValue; + } + + public void setBoolValue(boolean boolValue) { + this.boolValue = boolValue; + } + + public int getIntValue() { + return this.intValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + public Nest getNest() { + return this.nest; + } + + public static class Nest { + + private boolean boolValue; + + private int intValue; + + public boolean isBoolValue() { + return this.boolValue; + } + + public void setBoolValue(boolean boolValue) { + this.boolValue = boolValue; + } + + public int getIntValue() { + return this.intValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + } + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildProperties.java new file mode 100644 index 000000000000..a4832030b06d --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildProperties.java @@ -0,0 +1,61 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample.inheritance; + +public class ChildProperties extends BaseProperties { + + private long longValue; + + private final NestInChild childNest = new NestInChild(); + + public long getLongValue() { + return this.longValue; + } + + public void setLongValue(long longValue) { + this.longValue = longValue; + } + + public NestInChild getChildNest() { + return this.childNest; + } + + public static class NestInChild { + + private boolean boolValue; + + private int intValue; + + public boolean isBoolValue() { + return this.boolValue; + } + + public void setBoolValue(boolean boolValue) { + this.boolValue = boolValue; + } + + public int getIntValue() { + return this.intValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + } + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildPropertiesConfig.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildPropertiesConfig.java new file mode 100644 index 000000000000..3ff388df6e13 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/ChildPropertiesConfig.java @@ -0,0 +1,28 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample.inheritance; + +import org.springframework.boot.configurationsample.ConfigurationProperties; + +public class ChildPropertiesConfig { + + @ConfigurationProperties(prefix = "inheritance") + public ChildProperties childConfig() { + return new ChildProperties(); + } + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java new file mode 100644 index 000000000000..012cc9f26423 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java @@ -0,0 +1,36 @@ +package org.springframework.boot.configurationsample.inheritance; + +public class OverrideChildProperties extends BaseProperties { + + private long longValue; + + private final CustomNest nest = new CustomNest(); + + public long getLongValue() { + return this.longValue; + } + + public void setLongValue(long longValue) { + this.longValue = longValue; + } + + @Override + public CustomNest getNest() { + return this.nest; + } + + public static class CustomNest extends Nest { + + private long longValue; + + public long getLongValue() { + return this.longValue; + } + + public void setLongValue(long longValue) { + this.longValue = longValue; + } + + } + +} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildPropertiesConfig.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildPropertiesConfig.java new file mode 100644 index 000000000000..324d12c2a4dc --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildPropertiesConfig.java @@ -0,0 +1,28 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample.inheritance; + +import org.springframework.boot.configurationsample.ConfigurationProperties; + +public class OverrideChildPropertiesConfig { + + @ConfigurationProperties(prefix = "inheritance") + public OverrideChildProperties overrideChildProperties() { + return new OverrideChildProperties(); + } + +} From 09cd024817daa8cef3724ba3b0568bc2d0771b00 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 07:51:32 +0200 Subject: [PATCH 141/161] Upgrade to Spring Kafka 2.8.7 Closes gh-31350 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 1f32e526ec11..54ed33e55425 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1722,7 +1722,7 @@ bom { ] } } - library("Spring Kafka", "2.8.7-SNAPSHOT") { + library("Spring Kafka", "2.8.7") { group("org.springframework.kafka") { modules = [ "spring-kafka", From 1c2e3b731bc36f58065ecf5fb7b18703469bcbaa Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 07:52:14 +0200 Subject: [PATCH 142/161] Upgrade to Spring Kafka 2.8.7 Closes gh-31377 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 5946b8cdfa4b..fa67b564e1c9 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1725,7 +1725,7 @@ bom { ] } } - library("Spring Kafka", "2.8.7-SNAPSHOT") { + library("Spring Kafka", "2.8.7") { prohibit("[3.0.0-M1,)") { because "it uses Spring Framework 6" } From e74163704ca70be42521abfa0c0ec41de421c3f8 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 07:55:14 +0200 Subject: [PATCH 143/161] Upgrade to Dropwizard Metrics 4.2.10 Closes gh-31486 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 54ed33e55425..8f454a062d52 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -255,7 +255,7 @@ bom { ] } } - library("Dropwizard Metrics", "4.2.9") { + library("Dropwizard Metrics", "4.2.10") { group("io.dropwizard.metrics") { imports = [ "metrics-bom" From 72257ba302a0475a8cdd991b2ee48ebe2d105ccd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 07:55:16 +0200 Subject: [PATCH 144/161] Upgrade to Jetty 9.4.47.v20220610 Closes gh-31487 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 8f454a062d52..86b1f0cadd09 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -909,7 +909,7 @@ bom { ] } } - library("Jetty", "9.4.46.v20220331") { + library("Jetty", "9.4.47.v20220610") { prohibit("[10.0.0-alpha0,)") { because "it requires Java 11" } From 296e88db51e176b93c70845da8bfca5097447318 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 08:03:45 +0200 Subject: [PATCH 145/161] Upgrade to Dropwizard Metrics 4.2.10 Closes gh-31488 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index fa67b564e1c9..54819b935901 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -273,7 +273,7 @@ bom { ] } } - library("Dropwizard Metrics", "4.2.9") { + library("Dropwizard Metrics", "4.2.10") { group("io.dropwizard.metrics") { imports = [ "metrics-bom" From 7266dd52709e44a669508771ef5f475f64cd9d9e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 08:03:47 +0200 Subject: [PATCH 146/161] Upgrade to Jetty 9.4.47.v20220610 Closes gh-31489 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 54819b935901..b133600b3b27 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -940,7 +940,7 @@ bom { ] } } - library("Jetty", "9.4.46.v20220331") { + library("Jetty", "9.4.47.v20220610") { prohibit("[10.0.0-alpha0,)") { because "it requires Java 11" } From 4f6bc3c2e062f09473d2652eeb6d8a0489998bab Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 08:03:51 +0200 Subject: [PATCH 147/161] Upgrade to Kotlin Coroutines 1.6.3 Closes gh-31490 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index b133600b3b27..876f56ca4c89 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1100,7 +1100,7 @@ bom { ] } } - library("Kotlin Coroutines", "1.6.2") { + library("Kotlin Coroutines", "1.6.3") { group("org.jetbrains.kotlinx") { imports = [ "kotlinx-coroutines-bom" From f27adeb241c940a4f2a450a00793c5501139e086 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 08:03:53 +0200 Subject: [PATCH 148/161] Upgrade to Solr 8.11.2 Closes gh-31491 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 876f56ca4c89..477ecbcd2e88 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1627,7 +1627,7 @@ bom { ] } } - library("Solr", "8.11.1") { + library("Solr", "8.11.2") { group("org.apache.solr") { modules = [ "solr-analysis-extras", From 79d3e3080f6fb62405d6a92b10c8d1b5d430b984 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 22 Jun 2022 08:15:04 +0200 Subject: [PATCH 149/161] Polish --- .../inheritance/OverrideChildProperties.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java index 012cc9f26423..f8656314bbe4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/inheritance/OverrideChildProperties.java @@ -1,3 +1,19 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.configurationsample.inheritance; public class OverrideChildProperties extends BaseProperties { @@ -33,4 +49,4 @@ public void setLongValue(long longValue) { } -} \ No newline at end of file +} From 522ea0a90e369549a75ff035771587c0a971bad6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Jun 2022 07:22:48 +0100 Subject: [PATCH 150/161] Handle malformed JSON more consistently Closes gh-31301 --- .../boot/json/BasicJsonParser.java | 6 +++--- .../springframework/boot/json/GsonJsonParser.java | 8 +++++--- .../boot/json/AbstractJsonParserTests.java | 13 ++++++++++++- .../boot/json/YamlJsonParserTests.java | 15 ++++++++++++++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java index b24f98e36a0e..b867f7db0d7b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -39,12 +39,12 @@ public class BasicJsonParser extends AbstractJsonParser { @Override public Map parseMap(String json) { - return parseMap(json, this::parseMapInternal); + return tryParse(() -> parseMap(json, this::parseMapInternal), Exception.class); } @Override public List parseList(String json) { - return parseList(json, this::parseListInternal); + return tryParse(() -> parseList(json, this::parseListInternal), Exception.class); } private List parseListInternal(String json) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java index 9a20ede18f22..497eadb4f560 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -41,12 +41,14 @@ public class GsonJsonParser extends AbstractJsonParser { @Override public Map parseMap(String json) { - return parseMap(json, (trimmed) -> this.gson.fromJson(trimmed, MAP_TYPE.getType())); + return tryParse(() -> parseMap(json, (trimmed) -> this.gson.fromJson(trimmed, MAP_TYPE.getType())), + Exception.class); } @Override public List parseList(String json) { - return parseList(json, (trimmed) -> this.gson.fromJson(trimmed, LIST_TYPE.getType())); + return tryParse(() -> parseList(json, (trimmed) -> this.gson.fromJson(trimmed, LIST_TYPE.getType())), + Exception.class); } private static final class MapTypeToken extends TypeToken> { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java index 8878ca388d18..6ff6f1d64fd7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -175,4 +175,15 @@ void escapeDoubleQuote() { assertThat(map.get("foo")).isEqualTo("\"bar\""); } + @Test + void listWithMalformedMap() { + assertThatExceptionOfType(JsonParseException.class) + .isThrownBy(() -> this.parser.parseList("[tru,erqett,{\"foo\":fatrue,true,true,true,tr''ue}]")); + } + + @Test + void mapWithKeyAndNoValue() { + assertThatExceptionOfType(JsonParseException.class).isThrownBy(() -> this.parser.parseMap("{\"foo\"}")); + } + } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/YamlJsonParserTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/YamlJsonParserTests.java index e597ffb276ba..7df627fa0a77 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/YamlJsonParserTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/YamlJsonParserTests.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. @@ -16,6 +16,7 @@ package org.springframework.boot.json; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.constructor.ConstructorException; @@ -40,4 +41,16 @@ void customTypesAreNotLoaded() { .withCauseInstanceOf(IllegalStateException.class); } + @Test + @Override + @Disabled("SnakeYaml does not fail when a map is malformed") + void listWithMalformedMap() { + } + + @Test + @Override + @Disabled("SnakeYaml does not fail when a map has a key with no value") + void mapWithKeyAndNoValue() { + } + } From 17c757c600e229aef481fd9a279c249fee20b126 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 22 Jun 2022 20:38:19 +0100 Subject: [PATCH 151/161] Upgrade to Spring Integration 5.5.13 Closes gh-31482 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 86b1f0cadd09..0ff823253196 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1715,7 +1715,7 @@ bom { ] } } - library("Spring Integration", "5.5.12") { + library("Spring Integration", "5.5.13") { group("org.springframework.integration") { imports = [ "spring-integration-bom" From a784156f6651585f0f0217f1006d025db059dd2f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 22 Jun 2022 21:13:18 +0100 Subject: [PATCH 152/161] Revert "Start building against Spring Session 2021.1.4 snapshots" This reverts commit 2f40c52d810932ec7d65f413dc8c66024276f9a1. --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0ff823253196..4119ead9292c 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1767,7 +1767,7 @@ bom { ] } } - library("Spring Session Bom", "2021.1.4-SNAPSHOT") { + library("Spring Session Bom", "2021.1.3") { group("org.springframework.session") { imports = [ "spring-session-bom" From 3592292e4bf2496b4545d14e16ede4b1780ab774 Mon Sep 17 00:00:00 2001 From: Guirong Hu Date: Wed, 22 Jun 2022 20:58:43 +0800 Subject: [PATCH 153/161] Use ExceptionHandler when Spring MVC uses a different management port Update `CompositeHandlerExceptionResolver` to search for beans in all contexts. Note that `BeanFactoryUtils.beansOfTypeIncludingAncestors` cannot not be used since we need to pick up all beans, even if they have the same name. See gh-31495 --- .../CompositeHandlerExceptionResolver.java | 17 +++++- ...leRestControllerEndpointWithException.java | 55 +++++++++++++++++++ ...HandlerSampleActuatorApplicationTests.java | 53 ++++++++++++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java index 345617df912b..92892a4863a2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.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. @@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.HierarchicalBeanFactory; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; @@ -38,6 +40,7 @@ * @author Stephane Nicoll * @author Phillip Webb * @author Scott Frederick + * @author Guirong Hu */ class CompositeHandlerExceptionResolver implements HandlerExceptionResolver { @@ -57,8 +60,16 @@ public ModelAndView resolveException(HttpServletRequest request, HttpServletResp } private List extractResolvers() { - List list = new ArrayList<>( - this.beanFactory.getBeansOfType(HandlerExceptionResolver.class).values()); + List list = new ArrayList<>(); + BeanFactory beanFactory = this.beanFactory; + while (beanFactory != null) { + if (beanFactory instanceof ListableBeanFactory) { + list.addAll( + ((ListableBeanFactory) beanFactory).getBeansOfType(HandlerExceptionResolver.class).values()); + } + beanFactory = (beanFactory instanceof HierarchicalBeanFactory) + ? ((HierarchicalBeanFactory) beanFactory).getParentBeanFactory() : null; + } list.remove(this); AnnotationAwareOrderComparator.sort(list); if (list.isEmpty()) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java new file mode 100644 index 000000000000..26207123f151 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java @@ -0,0 +1,55 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package smoketest.actuator; + +import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The Sample rest controller endpoint with exception. + * + * @author Guirong Hu + */ +@Component +@RestControllerEndpoint(id = "exception") +public class SampleRestControllerEndpointWithException { + + @GetMapping("/") + public String exception() { + throw new CustomException(); + } + + @RestControllerAdvice + static class CustomExceptionHandler { + + @ExceptionHandler(CustomException.class) + ResponseEntity handleCustomException(CustomException e) { + return new ResponseEntity<>("this is a custom exception body", HttpStatus.I_AM_A_TEAPOT); + } + + } + + static class CustomException extends RuntimeException { + + } + +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java new file mode 100644 index 000000000000..be306f1fb8d8 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java @@ -0,0 +1,53 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package smoketest.actuator; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; +import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration tests for separate management and main service ports with Actuator's MVC + * {@link RestControllerEndpoint rest controller endpoints} and {@link ExceptionHandler + * exception handler}. + * + * @author Guirong Hu + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", "management.server.port=0" }) +class ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests { + + @LocalManagementPort + private int managementPort; + + @Test + void testExceptionHandlerRestControllerEndpoint() { + ResponseEntity entity = new TestRestTemplate("user", "password") + .getForEntity("http://localhost:" + this.managementPort + "/actuator/exception", String.class); + assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.I_AM_A_TEAPOT); + assertThat(entity.getBody()).isEqualTo("this is a custom exception body"); + } + +} From aed4c47adb8b572d3eb5ea6ebbbcb8f1aa849249 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 22 Jun 2022 16:13:03 -0700 Subject: [PATCH 154/161] Polish CompositeHandlerExceptionResolver See gh-31495 --- .../CompositeHandlerExceptionResolver.java | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java index 92892a4863a2..a7a257da3f4c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Objects; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -47,36 +46,45 @@ class CompositeHandlerExceptionResolver implements HandlerExceptionResolver { @Autowired private ListableBeanFactory beanFactory; - private List resolvers; + private transient List resolvers; @Override public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - if (this.resolvers == null) { - this.resolvers = extractResolvers(); + for (HandlerExceptionResolver resolver : getResolvers()) { + ModelAndView resolved = resolver.resolveException(request, response, handler, ex); + if (resolved != null) { + return resolved; + } } - return this.resolvers.stream().map((resolver) -> resolver.resolveException(request, response, handler, ex)) - .filter(Objects::nonNull).findFirst().orElse(null); + return null; } - private List extractResolvers() { - List list = new ArrayList<>(); - BeanFactory beanFactory = this.beanFactory; - while (beanFactory != null) { - if (beanFactory instanceof ListableBeanFactory) { - list.addAll( - ((ListableBeanFactory) beanFactory).getBeansOfType(HandlerExceptionResolver.class).values()); + private List getResolvers() { + List resolvers = this.resolvers; + if (resolvers == null) { + resolvers = new ArrayList<>(); + collectResolverBeans(resolvers, this.beanFactory); + resolvers.remove(this); + AnnotationAwareOrderComparator.sort(resolvers); + if (resolvers.isEmpty()) { + resolvers.add(new DefaultErrorAttributes()); + resolvers.add(new DefaultHandlerExceptionResolver()); } - beanFactory = (beanFactory instanceof HierarchicalBeanFactory) - ? ((HierarchicalBeanFactory) beanFactory).getParentBeanFactory() : null; + this.resolvers = resolvers; + } + return resolvers; + } + + private void collectResolverBeans(List resolvers, BeanFactory beanFactory) { + if (beanFactory instanceof ListableBeanFactory) { + ListableBeanFactory listableBeanFactory = (ListableBeanFactory) beanFactory; + resolvers.addAll(listableBeanFactory.getBeansOfType(HandlerExceptionResolver.class).values()); } - list.remove(this); - AnnotationAwareOrderComparator.sort(list); - if (list.isEmpty()) { - list.add(new DefaultErrorAttributes()); - list.add(new DefaultHandlerExceptionResolver()); + if (beanFactory instanceof HierarchicalBeanFactory) { + HierarchicalBeanFactory hierarchicalBeanFactory = (HierarchicalBeanFactory) beanFactory; + collectResolverBeans(resolvers, hierarchicalBeanFactory.getParentBeanFactory()); } - return list; } } From 1c7d99890e05201aefba6eb58d284ce0a11506a8 Mon Sep 17 00:00:00 2001 From: "Stern, Ittay (is9613)" Date: Wed, 1 Jun 2022 16:42:46 +0300 Subject: [PATCH 155/161] Allow spring.data.cassandra.config file to override default values Update `CassandraAutoConfiguration` so that properties in a `spring.data.cassandra.config` file can override the default values defined in `CassandraProperties`. This commit changes two things: 1. Any primitive on `CassandraProperties` are replaced with object values. This allows distinguishing between defaults values and no-values. Then CassandraAutoConfiguration.mapConfig() can use whenNonNull() predicate to ignore those. 2. `CassandraProperties` no longer populate default values on any property. With that, the defaults can be applied on top of the file spring.data.cassandra.config; i.e. the config file have higher precedence than the defaults, but lower that any spring.data.cassandra.* property. See gh-31238 --- .../cassandra/CassandraAutoConfiguration.java | 10 +++-- .../cassandra/CassandraProperties.java | 36 +++++++++++----- .../CassandraAutoConfigurationTests.java | 41 +++++++++++++++++++ .../cassandra/override-defaults.conf | 20 +++++++++ 4 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index 20882e550f2c..a36fed6b20b4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -126,7 +126,8 @@ private Config cassandraConfiguration(CassandraProperties properties) { private Config applyDefaultFallback(Config config) { ConfigFactory.invalidateCaches(); - return ConfigFactory.defaultOverrides().withFallback(config).withFallback(ConfigFactory.defaultReference()) + return ConfigFactory.defaultOverrides().withFallback(config) + .withFallback(mapConfig(CassandraProperties.defaults())).withFallback(ConfigFactory.defaultReference()) .resolve(); } @@ -153,9 +154,9 @@ private Config mapConfig(CassandraProperties properties) { mapPoolingOptions(properties, options); mapRequestOptions(properties, options); mapControlConnectionOptions(properties, options); - map.from(mapContactPoints(properties)) + map.from(mapContactPoints(properties)).whenNonNull() .to((contactPoints) -> options.add(DefaultDriverOption.CONTACT_POINTS, contactPoints)); - map.from(properties.getLocalDatacenter()).to( + map.from(properties.getLocalDatacenter()).whenHasText().to( (localDatacenter) -> options.add(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER, localDatacenter)); return options.build(); } @@ -210,7 +211,8 @@ private void mapControlConnectionOptions(CassandraProperties properties, Cassand } private List mapContactPoints(CassandraProperties properties) { - return properties.getContactPoints().stream() + List contactPoints = properties.getContactPoints(); + return (contactPoints == null) ? null : contactPoints.stream() .map((candidate) -> formatContactPoint(candidate, properties.getPort())).collect(Collectors.toList()); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index 17d99cf7696a..f8a5477e5da9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -38,6 +38,16 @@ @ConfigurationProperties(prefix = "spring.data.cassandra") public class CassandraProperties { + static CassandraProperties defaults() { + CassandraProperties properties = new CassandraProperties(); + + properties.setContactPoints(new ArrayList<>(Collections.singleton("127.0.0.1:9042"))); + properties.setCompression(Compression.NONE); + properties.getControlconnection().setTimeout(Duration.ofSeconds(5)); + + return properties; + } + /** * Location of the configuration file to use. */ @@ -57,7 +67,7 @@ public class CassandraProperties { * Cluster node addresses in the form 'host:port', or a simple 'host' to use the * configured port. */ - private final List contactPoints = new ArrayList<>(Collections.singleton("127.0.0.1:9042")); + private List contactPoints; /** * Port to use if a contact point does not specify one. @@ -83,7 +93,7 @@ public class CassandraProperties { /** * Compression supported by the Cassandra binary protocol. */ - private Compression compression = Compression.NONE; + private Compression compression; /** * Schema action to take at startup. @@ -143,6 +153,10 @@ public List getContactPoints() { return this.contactPoints; } + public void setContactPoints(List contactPoints) { + this.contactPoints = contactPoints; + } + public int getPort() { return this.port; } @@ -266,7 +280,7 @@ public static class Request { /** * How many rows will be retrieved simultaneously in a single network round-trip. */ - private int pageSize; + private Integer pageSize; private final Throttler throttler = new Throttler(); @@ -294,7 +308,7 @@ public void setSerialConsistency(DefaultConsistencyLevel serialConsistency) { this.serialConsistency = serialConsistency; } - public int getPageSize() { + public Integer getPageSize() { return this.pageSize; } @@ -347,7 +361,7 @@ public static class Controlconnection { /** * Timeout to use for control queries. */ - private Duration timeout = Duration.ofSeconds(5); + private Duration timeout; public Duration getTimeout() { return this.timeout; @@ -370,17 +384,17 @@ public static class Throttler { * Maximum number of requests that can be enqueued when the throttling threshold * is exceeded. */ - private int maxQueueSize; + private Integer maxQueueSize; /** * Maximum number of requests that are allowed to execute in parallel. */ - private int maxConcurrentRequests; + private Integer maxConcurrentRequests; /** * Maximum allowed request rate. */ - private int maxRequestsPerSecond; + private Integer maxRequestsPerSecond; /** * How often the throttler attempts to dequeue requests. Set this high enough that @@ -397,7 +411,7 @@ public void setType(ThrottlerType type) { this.type = type; } - public int getMaxQueueSize() { + public Integer getMaxQueueSize() { return this.maxQueueSize; } @@ -405,7 +419,7 @@ public void setMaxQueueSize(int maxQueueSize) { this.maxQueueSize = maxQueueSize; } - public int getMaxConcurrentRequests() { + public Integer getMaxConcurrentRequests() { return this.maxConcurrentRequests; } @@ -413,7 +427,7 @@ public void setMaxConcurrentRequests(int maxConcurrentRequests) { this.maxConcurrentRequests = maxConcurrentRequests; } - public int getMaxRequestsPerSecond() { + public Integer getMaxRequestsPerSecond() { return this.maxRequestsPerSecond; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java index ed05b182aa52..1975e4ff804c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java @@ -17,6 +17,8 @@ package org.springframework.boot.autoconfigure.cassandra; import java.time.Duration; +import java.util.Collections; +import java.util.List; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.CqlSession; @@ -28,6 +30,7 @@ import com.datastax.oss.driver.internal.core.session.throttling.ConcurrencyLimitingRequestThrottler; import com.datastax.oss.driver.internal.core.session.throttling.PassThroughRequestThrottler; import com.datastax.oss.driver.internal.core.session.throttling.RateLimitingRequestThrottler; +import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -244,6 +247,44 @@ void driverConfigLoaderWithConfigComplementSettings() { }); } + @Test // gh-31025 + void driverConfigLoaderWithConfigOverridesDefaults() { + String configLocation = "org/springframework/boot/autoconfigure/cassandra/override-defaults.conf"; + this.contextRunner.withPropertyValues("spring.data.cassandra.config=" + configLocation).run((context) -> { + assertThat(context).hasSingleBean(DriverConfigLoader.class); + + SoftAssertions softly = new SoftAssertions(); + + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("advanced session"); + + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getDuration(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofSeconds(2)); // default + + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getStringList(DefaultDriverOption.CONTACT_POINTS)).isEqualTo(Collections.singletonList("1.2.3.4:5678")); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getBoolean(DefaultDriverOption.RESOLVE_CONTACT_POINTS)).isFalse(); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getInt(DefaultDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(11); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)).isEqualTo("datacenter1"); + + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS)).isEqualTo(22); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND)).isEqualTo(33); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE)).isEqualTo(44); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getDuration(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)).isEqualTo(Duration.ofMillis(5555)); + softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() + .getString(DefaultDriverOption.PROTOCOL_COMPRESSION)).isEqualTo("SNAPPY"); + + softly.assertAll(); + }); + } + @Test void driverConfigLoaderWithConfigCreateProfiles() { String configLocation = "org/springframework/boot/autoconfigure/cassandra/profiles.conf"; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf new file mode 100644 index 000000000000..52115731ed3d --- /dev/null +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf @@ -0,0 +1,20 @@ +datastax-java-driver { + basic { + session-name = advanced session + load-balancing-policy { + local-datacenter = datacenter1 + } + request.page-size = 11 + contact-points = [ "1.2.3.4:5678" ] + } + advanced { + throttler { + max-concurrent-requests = 22 + max-requests-per-second = 33 + max-queue-size = 44 + } + control-connection.timeout = 5555 + protocol.compression = SNAPPY + resolve-contact-points = false + } +} From 904feb249006cd28464e0eef7da9dad43ced20fc Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 22 Jun 2022 18:59:51 -0700 Subject: [PATCH 156/161] Polish 'Allow spring.data.cassandra.config file to override default values' See gh-31238 --- .../cassandra/CassandraAutoConfiguration.java | 54 +++++++++++-------- .../cassandra/CassandraProperties.java | 12 ----- ...itional-spring-configuration-metadata.json | 4 ++ .../CassandraAutoConfigurationTests.java | 53 +++++++----------- .../cassandra/override-defaults.conf | 36 ++++++------- 5 files changed, 73 insertions(+), 86 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index a36fed6b20b4..8907a22633fd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.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. @@ -19,6 +19,7 @@ import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.time.Duration; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -63,6 +64,7 @@ * @author Eddú Meléndez * @author Stephane Nicoll * @author Steffen F. Qvistgaard + * @author Ittay Stern * @since 1.3.0 */ @Configuration(proxyBeanMethods = false) @@ -70,6 +72,15 @@ @EnableConfigurationProperties(CassandraProperties.class) public class CassandraAutoConfiguration { + private static final Config SPRING_BOOT_DEFAULTS; + static { + CassandraDriverOptions options = new CassandraDriverOptions(); + options.add(DefaultDriverOption.CONTACT_POINTS, Collections.singletonList("127.0.0.1:9042")); + options.add(DefaultDriverOption.PROTOCOL_COMPRESSION, "none"); + options.add(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, (int) Duration.ofSeconds(5).toMillis()); + SPRING_BOOT_DEFAULTS = options.build(); + } + @Bean @ConditionalOnMissingBean @Lazy @@ -118,43 +129,41 @@ public DriverConfigLoader cassandraDriverConfigLoader(CassandraProperties proper } private Config cassandraConfiguration(CassandraProperties properties) { - Config config = mapConfig(properties); - Resource configFile = properties.getConfig(); - return (configFile != null) ? applyDefaultFallback(config.withFallback(loadConfig(configFile))) - : applyDefaultFallback(config); - } - - private Config applyDefaultFallback(Config config) { ConfigFactory.invalidateCaches(); - return ConfigFactory.defaultOverrides().withFallback(config) - .withFallback(mapConfig(CassandraProperties.defaults())).withFallback(ConfigFactory.defaultReference()) - .resolve(); + Config config = ConfigFactory.defaultOverrides(); + config = config.withFallback(mapConfig(properties)); + if (properties.getConfig() != null) { + config = config.withFallback(loadConfig(properties.getConfig())); + } + config = config.withFallback(SPRING_BOOT_DEFAULTS); + config = config.withFallback(ConfigFactory.defaultReference()); + return config.resolve(); } - private Config loadConfig(Resource config) { + private Config loadConfig(Resource resource) { try { - return ConfigFactory.parseURL(config.getURL()); + return ConfigFactory.parseURL(resource.getURL()); } catch (IOException ex) { - throw new IllegalStateException("Failed to load cassandra configuration from " + config, ex); + throw new IllegalStateException("Failed to load cassandra configuration from " + resource, ex); } } private Config mapConfig(CassandraProperties properties) { CassandraDriverOptions options = new CassandraDriverOptions(); - PropertyMapper map = PropertyMapper.get(); + PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(properties.getSessionName()).whenHasText() .to((sessionName) -> options.add(DefaultDriverOption.SESSION_NAME, sessionName)); - map.from(properties::getUsername).whenNonNull() + map.from(properties::getUsername) .to((username) -> options.add(DefaultDriverOption.AUTH_PROVIDER_USER_NAME, username) .add(DefaultDriverOption.AUTH_PROVIDER_PASSWORD, properties.getPassword())); - map.from(properties::getCompression).whenNonNull() + map.from(properties::getCompression) .to((compression) -> options.add(DefaultDriverOption.PROTOCOL_COMPRESSION, compression)); mapConnectionOptions(properties, options); mapPoolingOptions(properties, options); mapRequestOptions(properties, options); mapControlConnectionOptions(properties, options); - map.from(mapContactPoints(properties)).whenNonNull() + map.from(mapContactPoints(properties)) .to((contactPoints) -> options.add(DefaultDriverOption.CONTACT_POINTS, contactPoints)); map.from(properties.getLocalDatacenter()).whenHasText().to( (localDatacenter) -> options.add(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER, localDatacenter)); @@ -211,9 +220,12 @@ private void mapControlConnectionOptions(CassandraProperties properties, Cassand } private List mapContactPoints(CassandraProperties properties) { - List contactPoints = properties.getContactPoints(); - return (contactPoints == null) ? null : contactPoints.stream() - .map((candidate) -> formatContactPoint(candidate, properties.getPort())).collect(Collectors.toList()); + if (properties.getContactPoints() != null) { + return properties.getContactPoints().stream() + .map((candidate) -> formatContactPoint(candidate, properties.getPort())) + .collect(Collectors.toList()); + } + return null; } private String formatContactPoint(String candidate, int port) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index f8a5477e5da9..9d273038714f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -17,8 +17,6 @@ package org.springframework.boot.autoconfigure.cassandra; import java.time.Duration; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; @@ -38,16 +36,6 @@ @ConfigurationProperties(prefix = "spring.data.cassandra") public class CassandraProperties { - static CassandraProperties defaults() { - CassandraProperties properties = new CassandraProperties(); - - properties.setContactPoints(new ArrayList<>(Collections.singleton("127.0.0.1:9042"))); - properties.setCompression(Compression.NONE); - properties.getControlconnection().setTimeout(Duration.ofSeconds(5)); - - return properties; - } - /** * Location of the configuration file to use. */ diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 1591c65a8473..7d2333fb69fe 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -492,6 +492,10 @@ "name": "spring.data.cassandra.connection.init-query-timeout", "defaultValue": "5s" }, + { + "name": "spring.data.cassandra.controlconnection.timeout", + "defaultValue": "5s" + }, { "name": "spring.data.cassandra.contact-points", "defaultValue": [ diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java index 1975e4ff804c..971ec02b7eb5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.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. @@ -18,7 +18,6 @@ import java.time.Duration; import java.util.Collections; -import java.util.List; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.CqlSession; @@ -30,7 +29,6 @@ import com.datastax.oss.driver.internal.core.session.throttling.ConcurrencyLimitingRequestThrottler; import com.datastax.oss.driver.internal.core.session.throttling.PassThroughRequestThrottler; import com.datastax.oss.driver.internal.core.session.throttling.RateLimitingRequestThrottler; -import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -46,6 +44,7 @@ * * @author Eddú Meléndez * @author Stephane Nicoll + * @author Ittay Stern */ class CassandraAutoConfigurationTests { @@ -247,41 +246,25 @@ void driverConfigLoaderWithConfigComplementSettings() { }); } - @Test // gh-31025 + @Test // gh-31238 void driverConfigLoaderWithConfigOverridesDefaults() { String configLocation = "org/springframework/boot/autoconfigure/cassandra/override-defaults.conf"; this.contextRunner.withPropertyValues("spring.data.cassandra.config=" + configLocation).run((context) -> { - assertThat(context).hasSingleBean(DriverConfigLoader.class); - - SoftAssertions softly = new SoftAssertions(); - - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("advanced session"); - - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getDuration(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofSeconds(2)); // default - - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getStringList(DefaultDriverOption.CONTACT_POINTS)).isEqualTo(Collections.singletonList("1.2.3.4:5678")); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getBoolean(DefaultDriverOption.RESOLVE_CONTACT_POINTS)).isFalse(); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getInt(DefaultDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(11); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)).isEqualTo("datacenter1"); - - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS)).isEqualTo(22); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND)).isEqualTo(33); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE)).isEqualTo(44); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getDuration(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)).isEqualTo(Duration.ofMillis(5555)); - softly.assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile() - .getString(DefaultDriverOption.PROTOCOL_COMPRESSION)).isEqualTo("SNAPPY"); - - softly.assertAll(); + DriverExecutionProfile actual = context.getBean(DriverConfigLoader.class).getInitialConfig() + .getDefaultProfile(); + assertThat(actual.getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("advanced session"); + assertThat(actual.getDuration(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofSeconds(2)); + assertThat(actual.getStringList(DefaultDriverOption.CONTACT_POINTS)) + .isEqualTo(Collections.singletonList("1.2.3.4:5678")); + assertThat(actual.getBoolean(DefaultDriverOption.RESOLVE_CONTACT_POINTS)).isFalse(); + assertThat(actual.getInt(DefaultDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(11); + assertThat(actual.getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)).isEqualTo("datacenter1"); + assertThat(actual.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS)).isEqualTo(22); + assertThat(actual.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND)).isEqualTo(33); + assertThat(actual.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE)).isEqualTo(44); + assertThat(actual.getDuration(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)) + .isEqualTo(Duration.ofMillis(5555)); + assertThat(actual.getString(DefaultDriverOption.PROTOCOL_COMPRESSION)).isEqualTo("SNAPPY"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf index 52115731ed3d..857df202fc6b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/override-defaults.conf @@ -1,20 +1,20 @@ datastax-java-driver { - basic { - session-name = advanced session - load-balancing-policy { - local-datacenter = datacenter1 - } - request.page-size = 11 - contact-points = [ "1.2.3.4:5678" ] - } - advanced { - throttler { - max-concurrent-requests = 22 - max-requests-per-second = 33 - max-queue-size = 44 - } - control-connection.timeout = 5555 - protocol.compression = SNAPPY - resolve-contact-points = false - } + basic { + session-name = advanced session + load-balancing-policy { + local-datacenter = datacenter1 + } + request.page-size = 11 + contact-points = [ "1.2.3.4:5678" ] + } + advanced { + throttler { + max-concurrent-requests = 22 + max-requests-per-second = 33 + max-queue-size = 44 + } + control-connection.timeout = 5555 + protocol.compression = SNAPPY + resolve-contact-points = false + } } From 6484be2aa5e7eb9308185c1e05ae8c9f182a9914 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 23 Jun 2022 08:37:51 +0200 Subject: [PATCH 157/161] Upgrade to Jetty 9.4.48.v20220622 Closes gh-31507 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 4119ead9292c..8ddb6a577f17 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -909,7 +909,7 @@ bom { ] } } - library("Jetty", "9.4.47.v20220610") { + library("Jetty", "9.4.48.v20220622") { prohibit("[10.0.0-alpha0,)") { because "it requires Java 11" } From 59764572713b9aaba3a7d1c7ea09473300754a5b Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 23 Jun 2022 08:41:19 +0200 Subject: [PATCH 158/161] Upgrade to Byte Buddy 1.12.11 Closes gh-31508 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index ca561b69de95..c7da471592c5 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -152,7 +152,7 @@ bom { ] } } - library("Byte Buddy", "1.12.10") { + library("Byte Buddy", "1.12.11") { group("net.bytebuddy") { modules = [ "byte-buddy", From a94e7d667209e322fadf7171fcf51c22084e3dc0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 23 Jun 2022 08:41:23 +0200 Subject: [PATCH 159/161] Upgrade to Jetty 9.4.48.v20220622 Closes gh-31509 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index c7da471592c5..1a388cf9d845 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -940,7 +940,7 @@ bom { ] } } - library("Jetty", "9.4.47.v20220610") { + library("Jetty", "9.4.48.v20220622") { prohibit("[10.0.0-alpha0,)") { because "it requires Java 11" } From 498f052a7a48349c81e7c3e0585be2260a7d4ee6 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 23 Jun 2022 11:53:56 +0200 Subject: [PATCH 160/161] Fix deprecation warning --- ...pointWithExceptionHandlerSampleActuatorApplicationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java index be306f1fb8d8..89e0392177f8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java @@ -18,10 +18,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; From 77beca96198c4124f56df508db008a5c13351ff3 Mon Sep 17 00:00:00 2001 From: Spring Builds Date: Thu, 23 Jun 2022 11:20:09 +0000 Subject: [PATCH 161/161] Release v2.7.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bdc15267753e..3dbb2374fc23 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.7.1-SNAPSHOT +version=2.7.1 org.gradle.caching=true org.gradle.parallel=true