Skip to content
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

Add support for tuning the code generation for bean property values #31427

Closed
wilkinsona opened this issue Oct 13, 2023 · 1 comment
Closed
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

Affects: 6.0

The failure described in spring-projects/spring-boot#37637 occurs because there's a bean property value that is an instance of MultipartConfigElement. The code generation that runs during AOT processing doesn't know how to handle such a value and it fails. This can be addressed by using an inner-bean to describe the multipart config but, as discussed with @snicoll, it would be nicer if this wasn't necessary.

This could perhaps be achieved by allowing custom org.springframework.beans.factory.aot.BeanDefinitionPropertyValueCodeGenerator.Delegate or similar implementations to be plugged in through aot.factories or some other mechanism.

@snicoll snicoll added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Oct 13, 2023
@snicoll snicoll added this to the 6.2.x milestone Oct 13, 2023
@snicoll
Copy link
Member

snicoll commented Oct 13, 2023

Thanks for the report.

I wonder if this goes in the territory of custom code generation or not. Registering a "generic" delegate that would handle MultipartConfigElement is probably more desirable unless there is special knowledge of how the instance is structured. We could change BeanDefinitionPropertyValueCodeGenerator so that it has a ClassLoader to load implementations from aot.factories.

There is then the question of ordering those instances against the default. Ideally the ones that are hard-coded should have a predictive order. so that you could eventually override some behavior.

@snicoll snicoll self-assigned this Oct 23, 2023
snicoll added a commit to snicoll/spring-framework that referenced this issue Oct 23, 2023
This commits allows ValueCodeGenerator$Delegate implementations to be
loaded from `META-INF/spring/aot.factories` and considered for code
generation of bean definition property values. This default behavior
in DefaultBeanRegistrationCodeFragments can be customized as usual.

Closes spring-projectsgh-31427
@snicoll snicoll modified the milestones: 6.2.x, 6.1.2 Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants