Skip to content

Commit 9e7f6ba

Browse files
committed
PathMatchingResourcePatternResolver consistently logs retrieval results
Issue: SPR-13923 (cherry picked from commit 449f704)
1 parent d8a7b6f commit 9e7f6ba

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -156,9 +156,9 @@
156156
* classpath:com/mycompany/**/service-context.xml
157157
* </pre>
158158
* is used to try to resolve it, the resolver will work off the (first) URL
159-
* returned by {@code getResource("com/mycompany");}. If this base package
160-
* node exists in multiple classloader locations, the actual end resource may
161-
* not be underneath. Therefore, preferably, use "{@code classpath*:}" with the same
159+
* returned by {@code getResource("com/mycompany");}. If this base package node
160+
* exists in multiple classloader locations, the actual end resource may not be
161+
* underneath. Therefore, preferably, use "{@code classpath*:}" with the same
162162
* Ant-style pattern in such a case, which will search <i>all</i> class path
163163
* locations that contain the root package.
164164
*
@@ -308,6 +308,9 @@ protected Resource[] findAllClassPathResources(String location) throws IOExcepti
308308
path = path.substring(1);
309309
}
310310
Set<Resource> result = doFindAllClassPathResources(path);
311+
if (logger.isDebugEnabled()) {
312+
logger.debug("Resolved classpath location [" + location + "] to resources " + result);
313+
}
311314
return result.toArray(new Resource[result.size()]);
312315
}
313316

@@ -316,6 +319,7 @@ protected Resource[] findAllClassPathResources(String location) throws IOExcepti
316319
* Called by {@link #findAllClassPathResources(String)}.
317320
* @param path the absolute path within the classpath (never a leading slash)
318321
* @return a mutable Set of matching Resource instances
322+
* @since 4.1.1
319323
*/
320324
protected Set<Resource> doFindAllClassPathResources(String path) throws IOException {
321325
Set<Resource> result = new LinkedHashSet<Resource>(16);
@@ -350,6 +354,7 @@ protected Resource convertClassLoaderURL(URL url) {
350354
* given set of resources in the form of pointers to the root of the jar file content.
351355
* @param classLoader the ClassLoader to search (including its ancestors)
352356
* @param result the set of resources to add jar roots to
357+
* @since 4.1.1
353358
*/
354359
protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
355360
if (classLoader instanceof URLClassLoader) {
@@ -381,6 +386,7 @@ protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource>
381386
}
382387
if (classLoader != null) {
383388
try {
389+
// Hierarchy traversal...
384390
addAllClassLoaderJarRoots(classLoader.getParent(), result);
385391
}
386392
catch (Exception ex) {

0 commit comments

Comments
 (0)