Skip to content

ConfigDataLocationResolvers and PropertySourceLoaders are loaded using a potentially different class loader #44427

Closed
@wilkinsona

Description

@wilkinsona

ConfigDataLocationResolver implementations are loaded using the resource loader's ClassLoader

protected ConfigDataLocationResolvers createConfigDataLocationResolvers(DeferredLogFactory logFactory,
ConfigurableBootstrapContext bootstrapContext, Binder binder, ResourceLoader resourceLoader) {
return new ConfigDataLocationResolvers(logFactory, bootstrapContext, binder, resourceLoader,
SpringFactoriesLoader.forDefaultResourceLocation(resourceLoader.getClassLoader()));
}

One of these implementations, StandardConfigDataLocationResolver, then uses its class's own class loader to load PropertySourceLoader implementations:

public StandardConfigDataLocationResolver(DeferredLogFactory logFactory, Binder binder,
ResourceLoader resourceLoader) {
this.logger = logFactory.getLog(StandardConfigDataLocationResolver.class);
this.propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class,
getClass().getClassLoader());
this.configNames = getConfigNames(binder);
this.resourceLoader = new LocationResourceLoader(resourceLoader);
}

For consistency, it should use the ResourceLoader that's passed into its constructor instead.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions