spring-projects / spring-projects/spring-framework
Review default exclusion mechanism in AOT-optimized contexts
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Right now, we do the following:
- If you implement
BeanFactoryInitializationAotProcessoron a bean, it is excluded (with no way to have it back) - If you implement
BeanRegistrationAotProcessoron a bean, it is excluded by default and that can changed by overriding theisBeanExcludedFromAotProcessingmethod - If you need to exclude additional components, you need to implement
BeanRegistrationExcludeFilter. Such interface must be implemented with eitherBeanFactoryInitializationAotProcessororBeanRegistrationAotProcessor.
The shortcut for "exclude myself" on BeanRegistrationAotProcessor is quite handy so I don't think relying only on the filter in its current form is ok. However, we should probably consider renaming the method as it doesn't exactly state what it does right now (the bean is processed and its contribution is recorded, but the bean itself won't be registered).
https://github.com/spring-projects/spring-boot/issues/32542 is another example. We have a BeanDefinitionRegistryPostProcessor that's exposed as a bean. The outcome of the post-processor (registering bean definitions) is recorded by AOT but the bean itself is contributed. This means that at runtime those bean definitions are contributed again.
Excluding them by default might not be the best option as they could potentially implement extra interface and having them excluded with no signal can be quite misleading.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading BeanFactoryInitializationAotProcessor, BeanRegistrationAotProcessor, and BeanRegistrationExcludeFilter to understand the current exclusion paths. Then review the BeanDefinitionRegistryPostProcessor example in issue #32542 and decide what behavior and method naming should be clarified or changed. Done means the exclusion mechanism has a settled, documented design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100