Skip to content

Cache ASM metadata at the context level [SPR-14654] #19219

Closed

Description

@spring-projects-issues

Stéphane Nicoll opened SPR-14654 and commented

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 valid ClassPathScanningCandidateComponentProvider 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?


Affects: 5.0 M1

Issue Links:

Referenced from: commits 7818c65

Activity

  1. spring-projects-issues commented on Dec 27, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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.

  2. added
    type: enhancement
    in: core
    on Jan 11, 2019
  3. added this to the 5.0 M4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions