You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cache ASM metadata at the context level [SPR-14654] #19219
While working on #16509 I noticed that caching several ClassPathScanningCandidateComponentProvider instances are instantiated when the application context is refreshed. With Spring Boot in particular, those instances are working on the same base package(s) with different filters.
In the end we scan the same Resources, load the same meta-data and figure out based on that if we have to include the component.
It would be much nicer if that information was cached for the duration of the refresh. Also, creating a validClassPathScanningCandidateComponentProvider requires you to pass the Environment and the ResourceLoader. Both of those are available from ApplicationContext. Perhaps the latter could take care of providing a shared instance or something?
I've introduced a general resource cache facility in DefaultResourceLoader which CachingMetadataReaderFactory automatically uses now when provided with an ApplicationContext as ResourceLoader (since all of our context implementations extend DefaultResourceLoader already). Any such caches get reused in an unbounded fashion up until AbstractApplicationContext's finish-refresh phase and automatically cleared then.
Activity
spring-projects-issues commentedon Dec 27, 2016
Juergen Hoeller commented
I've introduced a general resource cache facility in
DefaultResourceLoaderwhichCachingMetadataReaderFactoryautomatically uses now when provided with anApplicationContextasResourceLoader(since all of our context implementations extendDefaultResourceLoaderalready). Any such caches get reused in an unbounded fashion up untilAbstractApplicationContext's finish-refresh phase and automatically cleared then.