Be defensive about classloader in MessageSourceAutoConfiguration

Fixes gh-1960
This commit is contained in:
Dave Syer 2014-11-20 12:28:33 +00:00
parent d0f43d2e2b
commit 12a7df6c40
1 changed files with 9 additions and 4 deletions

View File

@ -137,7 +137,7 @@ public class MessageSourceAutoConfiguration {
return new SkipPatternPathMatchingResourcePatternResolver(classLoader) return new SkipPatternPathMatchingResourcePatternResolver(classLoader)
.getResources("classpath*:" + name + "*.properties"); .getResources("classpath*:" + name + "*.properties");
} }
catch (IOException ex) { catch (Exception ex) {
return NO_RESOURCES; return NO_RESOURCES;
} }
} }
@ -153,10 +153,15 @@ public class MessageSourceAutoConfiguration {
private static final ClassLoader ROOT_CLASSLOADER; private static final ClassLoader ROOT_CLASSLOADER;
static { static {
ClassLoader classLoader = ClassLoader.getSystemClassLoader(); ClassLoader classLoader = null;
try {
classLoader = ClassLoader.getSystemClassLoader();
while (classLoader.getParent() != null) { while (classLoader.getParent() != null) {
classLoader = classLoader.getParent(); classLoader = classLoader.getParent();
} }
}
catch (Throwable e) {
}
ROOT_CLASSLOADER = classLoader; ROOT_CLASSLOADER = classLoader;
} }