spring-projects / spring-projects/spring-framework

Review default exclusion mechanism in AOT-optimized contexts

Open
#29,280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core theme: aot type: task
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 BeanFactoryInitializationAotProcessor on a bean, it is excluded (with no way to have it back)
  • If you implement BeanRegistrationAotProcessor on a bean, it is excluded by default and that can changed by overriding the isBeanExcludedFromAotProcessing method
  • If you need to exclude additional components, you need to implement BeanRegistrationExcludeFilter. Such interface must be implemented with either BeanFactoryInitializationAotProcessor or BeanRegistrationAotProcessor.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.