Use TCCL at time of access for resource loading
Fixes gh-22119
This commit is contained in:
parent
f19f2b8714
commit
f86831da9c
|
|
@ -67,8 +67,7 @@ class DataSourceInitializer {
|
||||||
DataSourceInitializer(DataSource dataSource, DataSourceProperties properties, ResourceLoader resourceLoader) {
|
DataSourceInitializer(DataSource dataSource, DataSourceProperties properties, ResourceLoader resourceLoader) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.resourceLoader = (resourceLoader != null) ? resourceLoader
|
this.resourceLoader = (resourceLoader != null) ? resourceLoader : new DefaultResourceLoader(null);
|
||||||
: new DefaultResourceLoader(getClass().getClassLoader());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
|
||||||
|
|
||||||
private String charSet = "UTF-8";
|
private String charSet = "UTF-8";
|
||||||
|
|
||||||
private ResourceLoader resourceLoader = new DefaultResourceLoader(getClass().getClassLoader());
|
private ResourceLoader resourceLoader = new DefaultResourceLoader(null);
|
||||||
|
|
||||||
public MustacheResourceTemplateLoader() {
|
public MustacheResourceTemplateLoader() {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
|
||||||
private final Supplier<Collection<ProtocolResolver>> protocolResolvers;
|
private final Supplier<Collection<ProtocolResolver>> protocolResolvers;
|
||||||
|
|
||||||
ApplicationContextResourceLoader(Supplier<Collection<ProtocolResolver>> protocolResolvers) {
|
ApplicationContextResourceLoader(Supplier<Collection<ProtocolResolver>> protocolResolvers) {
|
||||||
// Use the restart class loader
|
super(null);
|
||||||
super(Thread.currentThread().getContextClassLoader());
|
|
||||||
this.protocolResolvers = protocolResolvers;
|
this.protocolResolvers = protocolResolvers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||||
setActiveProfiles(environment, config.getActiveProfiles());
|
setActiveProfiles(environment, config.getActiveProfiles());
|
||||||
}
|
}
|
||||||
ResourceLoader resourceLoader = (application.getResourceLoader() != null) ? application.getResourceLoader()
|
ResourceLoader resourceLoader = (application.getResourceLoader() != null) ? application.getResourceLoader()
|
||||||
: new DefaultResourceLoader(getClass().getClassLoader());
|
: new DefaultResourceLoader(null);
|
||||||
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, resourceLoader,
|
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, resourceLoader,
|
||||||
config.getPropertySourceLocations());
|
config.getPropertySourceLocations());
|
||||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, getInlinedProperties(config));
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, getInlinedProperties(config));
|
||||||
|
|
|
||||||
|
|
@ -550,7 +550,7 @@ public class SpringApplication {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader
|
ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader
|
||||||
: new DefaultResourceLoader(getClassLoader());
|
: new DefaultResourceLoader(null);
|
||||||
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);
|
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);
|
||||||
if (this.bannerMode == Mode.LOG) {
|
if (this.bannerMode == Mode.LOG) {
|
||||||
return bannerPrinter.print(environment, this.mainApplicationClass, logger);
|
return bannerPrinter.print(environment, this.mainApplicationClass, logger);
|
||||||
|
|
|
||||||
|
|
@ -326,8 +326,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||||
Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) {
|
Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.placeholdersResolver = new PropertySourcesPlaceholdersResolver(this.environment);
|
this.placeholdersResolver = new PropertySourcesPlaceholdersResolver(this.environment);
|
||||||
this.resourceLoader = (resourceLoader != null) ? resourceLoader
|
this.resourceLoader = (resourceLoader != null) ? resourceLoader : new DefaultResourceLoader(null);
|
||||||
: new DefaultResourceLoader(getClass().getClassLoader());
|
|
||||||
this.propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class,
|
this.propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class,
|
||||||
getClass().getClassLoader());
|
getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@ import org.springframework.util.ResourceUtils;
|
||||||
*/
|
*/
|
||||||
class StringToFileConverter implements Converter<String, File> {
|
class StringToFileConverter implements Converter<String, File> {
|
||||||
|
|
||||||
private static final ResourceLoader resourceLoader = new DefaultResourceLoader(
|
private static final ResourceLoader resourceLoader = new DefaultResourceLoader(null);
|
||||||
StringToFileConverter.class.getClassLoader());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File convert(String source) {
|
public File convert(String source) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue