Skip to content

Load ApplicationContextIntiailizers using the resource loader's class loader #14641

@pantherdd

Description

@pantherdd

When loading the Spring factories, SpringApplication.getSpringFactoriesInstances() uses the thread context classloader instead of the one passed at construction (inside the ResourceLoader). Using Thread.currentThread().getContextClassLoader() has caused an issue in my setup, as I was expecting the passed-in classloader to be used.

If you agree this is a bug, please use getClassLoader() in this method too, like the rest of the class does.

Also, there seem to be a total of 38 places in Spring Boot where this thread context classloader is used. Not sure if those are legitimate uses, but I'd be nice to check them whether they can also use the ResourceLoader instead, so as to avoid further bugs popping up because of the same root cause.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions