Browse Source

avoid NPE in PathMatchingResourcePatternResolver when initialized with null ClassLoader

pull/23217/head
Juergen Hoeller 17 years ago
parent
commit
647495edd3
  1. 8
      org.springframework.core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java
  2. 3
      org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

8
org.springframework.core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -74,15 +74,13 @@ public class DefaultResourceLoader implements ResourceLoader { @@ -74,15 +74,13 @@ public class DefaultResourceLoader implements ResourceLoader {
}
/**
* Return the ClassLoader to load class path resources with,
* or <code>null</code> if using the thread context class loader on actual access
* (applying to the thread that constructs the ClassPathResource object).
* Return the ClassLoader to load class path resources with.
* <p>Will get passed to ClassPathResource's constructor for all
* ClassPathResource objects created by this resource loader.
* @see ClassPathResource
*/
public ClassLoader getClassLoader() {
return this.classLoader;
return (this.classLoader != null ? this.classLoader : ClassUtils.getDefaultClassLoader());
}

3
org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -198,6 +198,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol @@ -198,6 +198,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
* Create a new PathMatchingResourcePatternResolver with a DefaultResourceLoader.
* @param classLoader the ClassLoader to load classpath resources with,
* or <code>null</code> for using the thread context class loader
* at the time of actual resource access
* @see org.springframework.core.io.DefaultResourceLoader
*/
public PathMatchingResourcePatternResolver(ClassLoader classLoader) {

Loading…
Cancel
Save