@@ -585,12 +585,14 @@ protected Resource[] findPathMatchingResources(String locationPattern) throws IO
585
585
String rootDirPath = determineRootDir (locationPattern );
586
586
String subPattern = locationPattern .substring (rootDirPath .length ());
587
587
588
- // Look for pre-cached root dir resources, either a direct match
589
- // or for a parent directory in the same classpath locations.
588
+ // Look for pre-cached root dir resources, either a direct match or
589
+ // a match for a parent directory in the same classpath locations.
590
590
Resource [] rootDirResources = this .rootDirCache .get (rootDirPath );
591
591
String actualRootPath = null ;
592
592
if (rootDirResources == null ) {
593
- // No direct match -> search for parent directory match.
593
+ // No direct match -> search for a common parent directory match
594
+ // (cached based on repeated searches in the same base location,
595
+ // in particular for different root directories in the same jar).
594
596
String commonPrefix = null ;
595
597
String existingPath = null ;
596
598
boolean commonUnique = true ;
@@ -618,12 +620,13 @@ else if (actualRootPath == null || path.length() > actualRootPath.length()) {
618
620
actualRootPath = path ;
619
621
}
620
622
}
621
- if (rootDirResources == null & StringUtils .hasLength (commonPrefix )) {
623
+ if (rootDirResources == null && StringUtils .hasLength (commonPrefix )) {
622
624
// Try common parent directory as long as it points to the same classpath locations.
623
625
rootDirResources = getResources (commonPrefix );
624
626
Resource [] existingResources = this .rootDirCache .get (existingPath );
625
627
if (existingResources != null && rootDirResources .length == existingResources .length ) {
626
- // Replace existing subdirectory cache entry with common parent directory.
628
+ // Replace existing subdirectory cache entry with common parent directory,
629
+ // avoiding repeated determination of root directories in the same jar.
627
630
this .rootDirCache .remove (existingPath );
628
631
this .rootDirCache .put (commonPrefix , rootDirResources );
629
632
actualRootPath = commonPrefix ;
0 commit comments