diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index be84de5929..d69433b15c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -156,9 +156,9 @@ import org.springframework.util.StringUtils; * classpath:com/mycompany/**/service-context.xml * * is used to try to resolve it, the resolver will work off the (first) URL - * returned by {@code getResource("com/mycompany");}. If this base package - * node exists in multiple classloader locations, the actual end resource may - * not be underneath. Therefore, preferably, use "{@code classpath*:}" with the same + * returned by {@code getResource("com/mycompany");}. If this base package node + * exists in multiple classloader locations, the actual end resource may not be + * underneath. Therefore, preferably, use "{@code classpath*:}" with the same * Ant-style pattern in such a case, which will search all class path * locations that contain the root package. * @@ -308,6 +308,9 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol path = path.substring(1); } Set result = doFindAllClassPathResources(path); + if (logger.isDebugEnabled()) { + logger.debug("Resolved classpath location [" + location + "] to resources " + result); + } return result.toArray(new Resource[result.size()]); } @@ -316,6 +319,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * Called by {@link #findAllClassPathResources(String)}. * @param path the absolute path within the classpath (never a leading slash) * @return a mutable Set of matching Resource instances + * @since 4.1.1 */ protected Set doFindAllClassPathResources(String path) throws IOException { Set result = new LinkedHashSet(16); @@ -350,6 +354,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * given set of resources in the form of pointers to the root of the jar file content. * @param classLoader the ClassLoader to search (including its ancestors) * @param result the set of resources to add jar roots to + * @since 4.1.1 */ protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set result) { if (classLoader instanceof URLClassLoader) { @@ -381,6 +386,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol } if (classLoader != null) { try { + // Hierarchy traversal... addAllClassLoaderJarRoots(classLoader.getParent(), result); } catch (Exception ex) {