Skip to content

feat: reuse shared metadata cache when scanning (#24887) (CP: 25.2)#24903

Merged
vaadin-bot merged 1 commit into
25.2from
cherry-pick-24887-to-25.2-1783054743795
Jul 3, 2026
Merged

feat: reuse shared metadata cache when scanning (#24887) (CP: 25.2)#24903
vaadin-bot merged 1 commit into
25.2from
cherry-pick-24887-to-25.2-1783054743795

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #24887 to branch 25.2.

Original PR description

Class and annotation scanning at startup runs many passes (routes, error handlers, web components, lookup, ...), each building a new ClassPathScanner. Because CustomResourceLoader does not extend DefaultResourceLoader, Spring's CachingMetadataReaderFactory falls back to a per-scan cache bounded to 256 entries instead of the application context's shared, unbounded resource cache. Parsed class metadata is therefore discarded and re-computed on every pass, slowing down startup on large classpaths.

Keep the filtering CustomResourceLoader as the scanner's pattern resolver so package and JAR filtering is preserved, and override the scanner's MetadataReaderFactory with a single shared CachingMetadataReaderFactory backed by the application context. As the context is a DefaultResourceLoader, the factory now stores metadata in the context's shared cache and reuses it across all scan passes.

Fixes #24881

Class and annotation scanning at startup runs many passes (routes, error
handlers, web components, lookup, ...), each building a new
`ClassPathScanner`. Because `CustomResourceLoader` does not extend
`DefaultResourceLoader`, Spring's `CachingMetadataReaderFactory` falls
back to a per-scan cache bounded to 256 entries instead of the
application context's shared, unbounded resource cache. Parsed class
metadata is therefore discarded and re-computed on every pass, slowing
down startup on large classpaths.

Keep the filtering `CustomResourceLoader` as the scanner's pattern
resolver so package and JAR filtering is preserved, and override the
scanner's `MetadataReaderFactory` with a single shared
`CachingMetadataReaderFactory` backed by the application context. As the
context is a `DefaultResourceLoader`, the factory now stores metadata in
the context's shared cache and reuses it across all scan passes.

Fixes #24881
@github-actions github-actions Bot added the +0.0.1 label Jul 3, 2026
@vaadin-bot

Copy link
Copy Markdown
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot]

@vaadin-bot vaadin-bot enabled auto-merge (squash) July 3, 2026 05:08
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Test Results

 1 455 files  ±0   1 455 suites  ±0   1h 25m 37s ⏱️ - 5m 16s
10 294 tests +1  10 226 ✅ +1  68 💤 ±0  0 ❌ ±0 
10 766 runs  +1  10 697 ✅ +1  69 💤 ±0  0 ❌ ±0 

Results for commit 4e5c0a3. ± Comparison against base commit 9fbe72f.

@vaadin-bot vaadin-bot merged commit 026f47e into 25.2 Jul 3, 2026
32 checks passed
@vaadin-bot vaadin-bot deleted the cherry-pick-24887-to-25.2-1783054743795 branch July 3, 2026 05:12
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants