Browse Source

avoid NPE in PathMatchingResourcePatternResolver when initialized with null ClassLoader

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@622 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 17 years ago
parent
commit
4ab4e93f45
  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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -74,15 +74,13 @@ public class DefaultResourceLoader implements ResourceLoader {
} }
/** /**
* Return the ClassLoader to load class path resources with, * 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).
* <p>Will get passed to ClassPathResource's constructor for all * <p>Will get passed to ClassPathResource's constructor for all
* ClassPathResource objects created by this resource loader. * ClassPathResource objects created by this resource loader.
* @see ClassPathResource * @see ClassPathResource
*/ */
public ClassLoader getClassLoader() { 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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -198,6 +198,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
* Create a new PathMatchingResourcePatternResolver with a DefaultResourceLoader. * Create a new PathMatchingResourcePatternResolver with a DefaultResourceLoader.
* @param classLoader the ClassLoader to load classpath resources with, * @param classLoader the ClassLoader to load classpath resources with,
* or <code>null</code> for using the thread context class loader * or <code>null</code> for using the thread context class loader
* at the time of actual resource access
* @see org.springframework.core.io.DefaultResourceLoader * @see org.springframework.core.io.DefaultResourceLoader
*/ */
public PathMatchingResourcePatternResolver(ClassLoader classLoader) { public PathMatchingResourcePatternResolver(ClassLoader classLoader) {

Loading…
Cancel
Save