From 40723c648d794554afbdd493e844580e03b33472 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Fri, 1 Aug 2025 11:53:25 -0400 Subject: [PATCH 1/5] Adds new ApiVersionCustomizer This allows users to create beans to customize ApiVersionConfigurer. --- .../autoconfigure/ApiVersionCustomizer.java | 35 ++++++++++++++++++ .../WebFluxAutoConfiguration.java | 7 +++- .../WebFluxAutoConfigurationTests.java | 6 ++++ .../autoconfigure/ApiVersionCustomizer.java | 36 +++++++++++++++++++ .../WebMvcAutoConfiguration.java | 7 +++- .../WebMvcAutoConfigurationTests.java | 5 +++ 6 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java create mode 100644 module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java new file mode 100644 index 000000000000..8b634b538322 --- /dev/null +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012-present 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.webflux.autoconfigure; + +import org.springframework.web.reactive.config.ApiVersionConfigurer; + +/** + * Customizer that can be used to modify the auto-configured + * {@link ApiVersionConfigurer} + * + * @author Spencer Gibb + * @since 4.0.0 + */ +public interface ApiVersionCustomizer { + + /** + * Customize the given configurer. + * @param apiVersionConfigurer the configurer to customize + */ + void customize(ApiVersionConfigurer apiVersionConfigurer); +} diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java index ff252ab8b917..a602382d42a9 100644 --- a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java @@ -184,13 +184,16 @@ static class WebFluxConfig implements WebFluxConfigurer { private final ObjectProvider apiVersionDeprecationHandler; + private final ObjectProvider apiVersionCustomizers; + WebFluxConfig(Environment environment, WebProperties webProperties, WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory, ObjectProvider resolvers, ObjectProvider codecCustomizers, ObjectProvider resourceHandlerRegistrationCustomizers, ObjectProvider viewResolvers, ObjectProvider apiVersionResolvers, ObjectProvider> apiVersionParser, - ObjectProvider apiVersionDeprecationHandler) { + ObjectProvider apiVersionDeprecationHandler, + ObjectProvider apiVersionCustomizers) { this.environment = environment; this.resourceProperties = webProperties.getResources(); this.webFluxProperties = webFluxProperties; @@ -202,6 +205,7 @@ static class WebFluxConfig implements WebFluxConfigurer { this.apiVersionResolvers = apiVersionResolvers; this.apiVersionParser = apiVersionParser; this.apiVersionDeprecationHandler = apiVersionDeprecationHandler; + this.apiVersionCustomizers = apiVersionCustomizers; } @Override @@ -284,6 +288,7 @@ public void configureApiVersioning(ApiVersionConfigurer configurer) { this.apiVersionResolvers.orderedStream().forEach(configurer::useVersionResolver); this.apiVersionParser.ifAvailable(configurer::setVersionParser); this.apiVersionDeprecationHandler.ifAvailable(configurer::setDeprecationHandler); + this.apiVersionCustomizers.orderedStream().forEach(customizer -> customizer.customize(configurer)); } private void configureApiVersioningUse(ApiVersionConfigurer configurer, Use use) { diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java index a8c21f690869..4be9975c498f 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java @@ -896,6 +896,7 @@ void apiVersionBeansAreInjected() { assertThat(versionStrategy).extracting("deprecationHandler") .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); + assertThat(versionStrategy).extracting("supportedVersionPredicate").isEqualTo(context.getBean(ApiVersionCustomizer.class)); }); } @@ -1312,6 +1313,11 @@ ApiVersionParser apiVersionParser() { return (version) -> String.valueOf(version); } + @Bean + ApiVersionCustomizer apiVersionCustomizer() { + return configurer -> configurer.setSupportedVersionPredicate(comparable -> true); + } + } } diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java new file mode 100644 index 000000000000..db9331ee0c39 --- /dev/null +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-present 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.webmvc.autoconfigure; + + +import org.springframework.web.servlet.config.annotation.ApiVersionConfigurer; + +/** + * Customizer that can be used to modify the auto-configured + * {@link ApiVersionConfigurer} + * + * @author Spencer Gibb + * @since 4.0.0 + */ +public interface ApiVersionCustomizer { + + /** + * Customize the given configurer. + * @param apiVersionConfigurer the configurer to customize + */ + void customize(ApiVersionConfigurer apiVersionConfigurer); +} diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java index 484557675b8e..daeaa7abd481 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java @@ -211,6 +211,8 @@ static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, Servlet private final ObjectProvider apiVersionDeprecationHandler; + private final ObjectProvider apiVersionCustomizers; + WebMvcAutoConfigurationAdapter(WebProperties webProperties, WebMvcProperties mvcProperties, ListableBeanFactory beanFactory, ObjectProvider messageConvertersProvider, ObjectProvider resourceHandlerRegistrationCustomizerProvider, @@ -218,7 +220,8 @@ static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, Servlet ObjectProvider> servletRegistrations, ObjectProvider apiVersionResolvers, ObjectProvider> apiVersionParser, - ObjectProvider apiVersionDeprecationHandler) { + ObjectProvider apiVersionDeprecationHandler, + ObjectProvider apiVersionCustomizers) { this.resourceProperties = webProperties.getResources(); this.mvcProperties = mvcProperties; this.beanFactory = beanFactory; @@ -229,6 +232,7 @@ static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, Servlet this.apiVersionResolvers = apiVersionResolvers; this.apiVersionParser = apiVersionParser; this.apiVersionDeprecationHandler = apiVersionDeprecationHandler; + this.apiVersionCustomizers = apiVersionCustomizers; } @Override @@ -398,6 +402,7 @@ public void configureApiVersioning(ApiVersionConfigurer configurer) { this.apiVersionResolvers.orderedStream().forEach(configurer::useVersionResolver); this.apiVersionParser.ifAvailable(configurer::setVersionParser); this.apiVersionDeprecationHandler.ifAvailable(configurer::setDeprecationHandler); + this.apiVersionCustomizers.orderedStream().forEach(customizer -> customizer.customize(configurer)); } private void configureApiVersioningUse(ApiVersionConfigurer configurer, Use use) { diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index a19c8b154a0d..311a18929eda 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -1101,6 +1101,7 @@ void apiVersionBeansAreInjected() { assertThat(versionStrategy).extracting("deprecationHandler") .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); + assertThat(versionStrategy).extracting("supportedVersionPredicate").isEqualTo(context.getBean(ApiVersionCustomizer.class)); }); } @@ -1683,6 +1684,10 @@ ApiVersionParser apiVersionParser() { return (version) -> String.valueOf(version); } + @Bean + ApiVersionCustomizer apiVersionCustomizer() { + return configurer -> configurer.setSupportedVersionPredicate(comparable -> true); + } } } From 13dcacc2d58b857f96e743a722e31c8fd0a63933 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Fri, 1 Aug 2025 13:42:36 -0400 Subject: [PATCH 2/5] Formatting --- .../boot/webflux/autoconfigure/ApiVersionCustomizer.java | 4 ++-- .../webflux/autoconfigure/WebFluxAutoConfigurationTests.java | 3 ++- .../boot/webmvc/autoconfigure/ApiVersionCustomizer.java | 5 ++--- .../webmvc/autoconfigure/WebMvcAutoConfigurationTests.java | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java index 8b634b538322..54b8506a5167 100644 --- a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java @@ -19,8 +19,7 @@ import org.springframework.web.reactive.config.ApiVersionConfigurer; /** - * Customizer that can be used to modify the auto-configured - * {@link ApiVersionConfigurer} + * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer} * * @author Spencer Gibb * @since 4.0.0 @@ -32,4 +31,5 @@ public interface ApiVersionCustomizer { * @param apiVersionConfigurer the configurer to customize */ void customize(ApiVersionConfigurer apiVersionConfigurer); + } diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java index 4be9975c498f..8444ba822db3 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java @@ -896,7 +896,8 @@ void apiVersionBeansAreInjected() { assertThat(versionStrategy).extracting("deprecationHandler") .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); - assertThat(versionStrategy).extracting("supportedVersionPredicate").isEqualTo(context.getBean(ApiVersionCustomizer.class)); + assertThat(versionStrategy).extracting("supportedVersionPredicate") + .isEqualTo(context.getBean(ApiVersionCustomizer.class)); }); } diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java index db9331ee0c39..8877c39bb093 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java @@ -16,12 +16,10 @@ package org.springframework.boot.webmvc.autoconfigure; - import org.springframework.web.servlet.config.annotation.ApiVersionConfigurer; /** - * Customizer that can be used to modify the auto-configured - * {@link ApiVersionConfigurer} + * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer} * * @author Spencer Gibb * @since 4.0.0 @@ -33,4 +31,5 @@ public interface ApiVersionCustomizer { * @param apiVersionConfigurer the configurer to customize */ void customize(ApiVersionConfigurer apiVersionConfigurer); + } diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index 311a18929eda..6a6d7a11a2ec 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -1101,7 +1101,8 @@ void apiVersionBeansAreInjected() { assertThat(versionStrategy).extracting("deprecationHandler") .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); - assertThat(versionStrategy).extracting("supportedVersionPredicate").isEqualTo(context.getBean(ApiVersionCustomizer.class)); + assertThat(versionStrategy).extracting("supportedVersionPredicate") + .isEqualTo(context.getBean(ApiVersionCustomizer.class)); }); } @@ -1688,6 +1689,7 @@ ApiVersionParser apiVersionParser() { ApiVersionCustomizer apiVersionCustomizer() { return configurer -> configurer.setSupportedVersionPredicate(comparable -> true); } + } } From 3d634ad4ff5f140af7bba52c25e05e5525ece3e0 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Fri, 1 Aug 2025 14:55:20 -0400 Subject: [PATCH 3/5] Checkstyle --- .../boot/webflux/autoconfigure/ApiVersionCustomizer.java | 2 +- .../boot/webflux/autoconfigure/WebFluxAutoConfiguration.java | 2 +- .../webflux/autoconfigure/WebFluxAutoConfigurationTests.java | 2 +- .../boot/webmvc/autoconfigure/ApiVersionCustomizer.java | 2 +- .../boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java | 2 +- .../boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java index 54b8506a5167..15f6124eccd8 100644 --- a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/ApiVersionCustomizer.java @@ -19,7 +19,7 @@ import org.springframework.web.reactive.config.ApiVersionConfigurer; /** - * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer} + * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer}. * * @author Spencer Gibb * @since 4.0.0 diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java index a602382d42a9..7fdd04c6085b 100644 --- a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfiguration.java @@ -288,7 +288,7 @@ public void configureApiVersioning(ApiVersionConfigurer configurer) { this.apiVersionResolvers.orderedStream().forEach(configurer::useVersionResolver); this.apiVersionParser.ifAvailable(configurer::setVersionParser); this.apiVersionDeprecationHandler.ifAvailable(configurer::setDeprecationHandler); - this.apiVersionCustomizers.orderedStream().forEach(customizer -> customizer.customize(configurer)); + this.apiVersionCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configurer)); } private void configureApiVersioningUse(ApiVersionConfigurer configurer, Use use) { diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java index 8444ba822db3..8656ea79e64c 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java @@ -1316,7 +1316,7 @@ ApiVersionParser apiVersionParser() { @Bean ApiVersionCustomizer apiVersionCustomizer() { - return configurer -> configurer.setSupportedVersionPredicate(comparable -> true); + return configurer -> configurer.setSupportedVersionPredicate((comparable) -> true); } } diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java index 8877c39bb093..27723d1a5a31 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/ApiVersionCustomizer.java @@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.ApiVersionConfigurer; /** - * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer} + * Customizer that can be used to modify the auto-configured {@link ApiVersionConfigurer}. * * @author Spencer Gibb * @since 4.0.0 diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java index daeaa7abd481..2321166991b1 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java @@ -402,7 +402,7 @@ public void configureApiVersioning(ApiVersionConfigurer configurer) { this.apiVersionResolvers.orderedStream().forEach(configurer::useVersionResolver); this.apiVersionParser.ifAvailable(configurer::setVersionParser); this.apiVersionDeprecationHandler.ifAvailable(configurer::setDeprecationHandler); - this.apiVersionCustomizers.orderedStream().forEach(customizer -> customizer.customize(configurer)); + this.apiVersionCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configurer)); } private void configureApiVersioningUse(ApiVersionConfigurer configurer, Use use) { diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index 6a6d7a11a2ec..672000471130 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -1687,7 +1687,7 @@ ApiVersionParser apiVersionParser() { @Bean ApiVersionCustomizer apiVersionCustomizer() { - return configurer -> configurer.setSupportedVersionPredicate(comparable -> true); + return configurer -> configurer.setSupportedVersionPredicate((comparable) -> true); } } From 1f7515d988682560e2365a2d81edc767d81f9436 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Fri, 1 Aug 2025 14:56:30 -0400 Subject: [PATCH 4/5] Checkstyle --- .../webflux/autoconfigure/WebFluxAutoConfigurationTests.java | 2 +- .../boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java index 8656ea79e64c..6705312a7166 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java @@ -1316,7 +1316,7 @@ ApiVersionParser apiVersionParser() { @Bean ApiVersionCustomizer apiVersionCustomizer() { - return configurer -> configurer.setSupportedVersionPredicate((comparable) -> true); + return (configurer) -> configurer.setSupportedVersionPredicate((comparable) -> true); } } diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index 672000471130..3996f5e08047 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -1687,7 +1687,7 @@ ApiVersionParser apiVersionParser() { @Bean ApiVersionCustomizer apiVersionCustomizer() { - return configurer -> configurer.setSupportedVersionPredicate((comparable) -> true); + return (configurer) -> configurer.setSupportedVersionPredicate((comparable) -> true); } } From cfb037ede681b10ef4641109d01072110428b00c Mon Sep 17 00:00:00 2001 From: spencergibb Date: Fri, 1 Aug 2025 16:39:20 -0400 Subject: [PATCH 5/5] Fix tests to compare predicate rather than customizer --- .../WebFluxAutoConfigurationTests.java | 14 +++++++++++--- .../WebMvcAutoConfigurationTests.java | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java index 6705312a7166..526aac70ec26 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java @@ -31,6 +31,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import java.util.function.Predicate; import jakarta.validation.ValidatorFactory; import org.aspectj.lang.JoinPoint; @@ -45,6 +46,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.http.codec.CodecCustomizer; @@ -897,7 +899,7 @@ void apiVersionBeansAreInjected() { .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); assertThat(versionStrategy).extracting("supportedVersionPredicate") - .isEqualTo(context.getBean(ApiVersionCustomizer.class)); + .isEqualTo(context.getBean("supportedVersionPredicate")); }); } @@ -1315,8 +1317,14 @@ ApiVersionParser apiVersionParser() { } @Bean - ApiVersionCustomizer apiVersionCustomizer() { - return (configurer) -> configurer.setSupportedVersionPredicate((comparable) -> true); + Predicate> supportedVersionPredicate() { + return (comparable) -> true; + } + + @Bean + ApiVersionCustomizer apiVersionCustomizer( + @Qualifier("supportedVersionPredicate") Predicate> supportedVersionPredicate) { + return (configurer) -> configurer.setSupportedVersionPredicate(supportedVersionPredicate); } } diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index 3996f5e08047..434d123de200 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -32,6 +32,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import java.util.function.Predicate; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -43,6 +44,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; @@ -1102,7 +1104,7 @@ void apiVersionBeansAreInjected() { .isEqualTo(context.getBean(ApiVersionDeprecationHandler.class)); assertThat(versionStrategy).extracting("versionParser").isEqualTo(context.getBean(ApiVersionParser.class)); assertThat(versionStrategy).extracting("supportedVersionPredicate") - .isEqualTo(context.getBean(ApiVersionCustomizer.class)); + .isEqualTo(context.getBean("supportedVersionPredicate")); }); } @@ -1686,8 +1688,14 @@ ApiVersionParser apiVersionParser() { } @Bean - ApiVersionCustomizer apiVersionCustomizer() { - return (configurer) -> configurer.setSupportedVersionPredicate((comparable) -> true); + Predicate> supportedVersionPredicate() { + return (comparable) -> true; + } + + @Bean + ApiVersionCustomizer apiVersionCustomizer( + @Qualifier("supportedVersionPredicate") Predicate> supportedVersionPredicate) { + return (configurer) -> configurer.setSupportedVersionPredicate(supportedVersionPredicate); } }