Skip to content

Optimize cache used in AutowiredAnnotationBeanPostProcessor #28293

Closed
@philwebb

Description

@philwebb

Currently AutowiredAnnotationBeanPostProcessor has a few caches that aren't providing that much in a typical application. They're also no cleared once a context has been refreshed.

Specifically:

  • candidateConstructorCache is not hit in a typical Spring Boot application and seems unnecessary if there's only a single constructor.
  • injectionMetadataCache is typically hit twice for singletons and always once after the other. The calls come from postProcessProperties and postProcessMergedBeanDefinition, both from doCreateBean. We could perhaps get away with a single element cache (at least for singletons).
  • @Lookup support happens for each class and also uses a cache. It's not a particularly common pattern anymore and it would be nice if it could be skipped if we know it's not in use. Perhaps we can skip it for auto-configuration classes.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions