From e982136f5eef28950dc86b4a755db4de6e03326c Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Fri, 14 Feb 2025 00:26:01 +0700 Subject: [PATCH 1/2] Implement RuntimeHintsRegistrar See gh-44266 --- .../FreeMarkerTemplateAvailabilityProvider.java | 12 +++++------- .../template/GroovyTemplateAvailabilityProvider.java | 12 +++++------- .../http/HttpMessageConvertersAutoConfiguration.java | 11 +++++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java index 4209bca7c9a..10f9fed1ceb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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 java.util.Arrays; import java.util.List; import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider; import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar; @@ -65,16 +66,13 @@ public class FreeMarkerTemplateAvailabilityProvider extends PathBasedTemplateAva } - static class FreeMarkerTemplateAvailabilityRuntimeHints extends BindableRuntimeHintsRegistrar { - - FreeMarkerTemplateAvailabilityRuntimeHints() { - super(FreeMarkerTemplateAvailabilityProperties.class); - } + static class FreeMarkerTemplateAvailabilityRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { if (ClassUtils.isPresent(REQUIRED_CLASS_NAME, classLoader)) { - super.registerHints(hints, classLoader); + BindableRuntimeHintsRegistrar.forTypes(FreeMarkerTemplateAvailabilityProperties.class) + .registerHints(hints, classLoader); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java index ae67f961a15..37beb02a51c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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 java.util.Arrays; import java.util.List; import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider; import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar; @@ -65,16 +66,13 @@ public class GroovyTemplateAvailabilityProvider extends PathBasedTemplateAvailab } - static class GroovyTemplateAvailabilityRuntimeHints extends BindableRuntimeHintsRegistrar { - - GroovyTemplateAvailabilityRuntimeHints() { - super(GroovyTemplateAvailabilityProperties.class); - } + static class GroovyTemplateAvailabilityRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { if (ClassUtils.isPresent(REQUIRED_CLASS_NAME, classLoader)) { - super.registerHints(hints, classLoader); + BindableRuntimeHintsRegistrar.forTypes(GroovyTemplateAvailabilityProperties.class) + .registerHints(hints, classLoader); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java index 7b7e9134b5b..fe50c8eab9c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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,8 @@ package org.springframework.boot.autoconfigure.http; +import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -100,10 +102,11 @@ public class HttpMessageConvertersAutoConfiguration { } - static class HttpMessageConvertersAutoConfigurationRuntimeHints extends BindableRuntimeHintsRegistrar { + static class HttpMessageConvertersAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar { - HttpMessageConvertersAutoConfigurationRuntimeHints() { - super(Encoding.class); + @Override + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + BindableRuntimeHintsRegistrar.forTypes(Encoding.class).registerHints(hints, classLoader); } } From f3ce5bca0cab4db84e6b63b004d8749a372bc1ed Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Fri, 14 Feb 2025 00:31:57 +0700 Subject: [PATCH 2/2] Clarifyt when UserDetailsService auto-configuration will back off See gh-44267 Signed-off-by: Tran Ngoc Nhan --- .../antora/modules/reference/pages/web/spring-security.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/web/spring-security.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/web/spring-security.adoc index bfdff877ab3..3fe36cc92e2 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/web/spring-security.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/web/spring-security.adoc @@ -40,7 +40,7 @@ javadoc:org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConf To completely switch off the default web application security configuration, including Actuator security, or to combine multiple Spring Security components such as OAuth2 Client and Resource Server, add a bean of type javadoc:org.springframework.security.web.SecurityFilterChain[] (doing so does not disable the javadoc:org.springframework.security.core.userdetails.UserDetailsService[] configuration). To also switch off the javadoc:org.springframework.security.core.userdetails.UserDetailsService[] configuration, add a bean of type javadoc:org.springframework.security.core.userdetails.UserDetailsService[], javadoc:org.springframework.security.authentication.AuthenticationProvider[], or javadoc:org.springframework.security.authentication.AuthenticationManager[]. -The auto-configuration of a javadoc:org.springframework.security.core.userdetails.UserDetailsService[] will also back off any of the following Spring Security modules is on the classpath: +The auto-configuration of a javadoc:org.springframework.security.core.userdetails.UserDetailsService[] will also back off when any of the following Spring Security modules is on the classpath: - `spring-security-oauth2-client` - `spring-security-oauth2-resource-server`