Skip to content

Prevent cache pollution by storing only the factories #34732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philwebb
Copy link
Member

@philwebb philwebb commented Apr 9, 2025

Update SpringFactoriesLoader so that the cache stores only the factories and not the complete loader.

Prior to this commit, if a cache entry was added with the thread conect classloader, the loader instance would a added and the classloader stored. If the thread context classloader subsequently changes, and a call is made to forDefaultResourceLocation with null for the classloader, the cached entry would be used which contains the older classloader.

Update `SpringFactoriesLoader` so that the cache stores only the
factories and not the complete loader.

Prior to this commit, if a cache entry was added with the thread
conect classloader, the loader instance would a added and the
classloader stored. If the thread context classloader subsequently
changes, and a call is made to `forDefaultResourceLocation` with
`null` for the classloader, the cached entry would be used which
contains the older classloader.

Fixes spring-projectsgh-34732
@philwebb philwebb force-pushed the factories-loader-cache-pollution branch from f7af69c to 6f59e55 Compare April 9, 2025 21:47
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 9, 2025
philwebb added a commit to spring-projects/spring-boot that referenced this pull request Apr 9, 2025
Update `SpringApplication` to work around `SpringFactoriesLoader`
cache pollution by loading factories using a `null` class loader.

See spring-projects/spring-framework#34732
for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants