-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid unnecessary CGLIB processing on configuration classes #34486
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Comments
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Mar 29, 2025
This commit addresses a regression introduced in 6.2.4 in conjunction with spring-projects#34486. See spring-projectsgh-34486 Closes spring-projectsgh-34663
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Mar 31, 2025
Historically, @Configuration classes that did not declare @Bean methods were allowed to be abstract. However, the changes made in 76a6b9ea79 introduced a regression that prevents such classes from being abstract, resulting in a BeanInstantiationException. This change in behavior is caused by the fact that such a @Configuration class is no longer replaced by a concrete subclass created dynamically by CGLIB. This commit restores support for abstract @Configuration classes without @Bean methods by modifying the "no enhancement required" check in ConfigurationClassParser. See spring-projectsgh-34486 Closes spring-projectsgh-34663
sbrannen
added a commit
that referenced
this issue
Mar 31, 2025
Historically, @Configuration classes that did not declare @Bean methods were allowed to be abstract. However, the changes made in 76a6b9ea79 introduced a regression that prevents such classes from being abstract, resulting in a BeanInstantiationException. This change in behavior is caused by the fact that such a @Configuration class is no longer replaced by a concrete subclass created dynamically by CGLIB. This commit restores support for abstract @Configuration classes without @Bean methods by modifying the "no enhancement required" check in ConfigurationClassParser. See gh-34486 Closes gh-34663
sbrannen
added a commit
that referenced
this issue
Mar 31, 2025
Historically, @Configuration classes that did not declare @Bean methods were allowed to be abstract. However, the changes made in 76a6b9ea79 introduced a regression that prevents such classes from being abstract, resulting in a BeanInstantiationException. This change in behavior is caused by the fact that such a @Configuration class is no longer replaced by a concrete subclass created dynamically by CGLIB. This commit restores support for abstract @Configuration classes without @Bean methods by modifying the "no enhancement required" check in ConfigurationClassParser. See gh-34486 Closes gh-34663 (cherry picked from commit 044258f)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
If a
@Configuration
class does not declare (or inherit) any instance-level@Bean
methods, generating an enhanced subclass with CGLIB is not adding any value. This is particularly likely for "holder"-like configuration classes with just imports, not least of it all common@SpringBootApplication
classes. We can entirely skip CGLIB processing for such classes, also not incurring unnecessary potential for CGLIB class cache failures/fallbacks (#34423).The text was updated successfully, but these errors were encountered: