Skip to content

Commit

Permalink
Use TCCL at time of access for resource loading
Browse files Browse the repository at this point in the history
Fixes gh-22119
  • Loading branch information
wilkinsona committed Jun 30, 2020
1 parent f19f2b8 commit f86831d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
Expand Up @@ -67,8 +67,7 @@ class DataSourceInitializer {
DataSourceInitializer(DataSource dataSource, DataSourceProperties properties, ResourceLoader resourceLoader) {
this.dataSource = dataSource;
this.properties = properties;
this.resourceLoader = (resourceLoader != null) ? resourceLoader
: new DefaultResourceLoader(getClass().getClassLoader());
this.resourceLoader = (resourceLoader != null) ? resourceLoader : new DefaultResourceLoader(null);
}

/**
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL

private String charSet = "UTF-8";

private ResourceLoader resourceLoader = new DefaultResourceLoader(getClass().getClassLoader());
private ResourceLoader resourceLoader = new DefaultResourceLoader(null);

public MustacheResourceTemplateLoader() {
}
Expand Down
Expand Up @@ -238,8 +238,7 @@ private static class ApplicationContextResourceLoader extends DefaultResourceLoa
private final Supplier<Collection<ProtocolResolver>> protocolResolvers;

ApplicationContextResourceLoader(Supplier<Collection<ProtocolResolver>> protocolResolvers) {
// Use the restart class loader
super(Thread.currentThread().getContextClassLoader());
super(null);
this.protocolResolvers = protocolResolvers;
}

Expand Down
Expand Up @@ -95,7 +95,7 @@ public ApplicationContext loadContext(MergedContextConfiguration config) throws
setActiveProfiles(environment, config.getActiveProfiles());
}
ResourceLoader resourceLoader = (application.getResourceLoader() != null) ? application.getResourceLoader()
: new DefaultResourceLoader(getClass().getClassLoader());
: new DefaultResourceLoader(null);
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, resourceLoader,
config.getPropertySourceLocations());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, getInlinedProperties(config));
Expand Down
Expand Up @@ -550,7 +550,7 @@ private Banner printBanner(ConfigurableEnvironment environment) {
return null;
}
ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader
: new DefaultResourceLoader(getClassLoader());
: new DefaultResourceLoader(null);
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);
if (this.bannerMode == Mode.LOG) {
return bannerPrinter.print(environment, this.mainApplicationClass, logger);
Expand Down
Expand Up @@ -326,8 +326,7 @@ private class Loader {
Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) {
this.environment = environment;
this.placeholdersResolver = new PropertySourcesPlaceholdersResolver(this.environment);
this.resourceLoader = (resourceLoader != null) ? resourceLoader
: new DefaultResourceLoader(getClass().getClassLoader());
this.resourceLoader = (resourceLoader != null) ? resourceLoader : new DefaultResourceLoader(null);
this.propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class,
getClass().getClassLoader());
}
Expand Down
Expand Up @@ -33,8 +33,7 @@
*/
class StringToFileConverter implements Converter<String, File> {

private static final ResourceLoader resourceLoader = new DefaultResourceLoader(
StringToFileConverter.class.getClassLoader());
private static final ResourceLoader resourceLoader = new DefaultResourceLoader(null);

@Override
public File convert(String source) {
Expand Down

0 comments on commit f86831d

Please sign in to comment.