Skip to content

Commit 14bc0d6

Browse files
committed
Fix typo in condition check
See gh-21190
1 parent 3bd342e commit 14bc0d6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,14 @@ protected Resource[] findPathMatchingResources(String locationPattern) throws IO
585585
String rootDirPath = determineRootDir(locationPattern);
586586
String subPattern = locationPattern.substring(rootDirPath.length());
587587

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.
590590
Resource[] rootDirResources = this.rootDirCache.get(rootDirPath);
591591
String actualRootPath = null;
592592
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).
594596
String commonPrefix = null;
595597
String existingPath = null;
596598
boolean commonUnique = true;
@@ -618,12 +620,13 @@ else if (actualRootPath == null || path.length() > actualRootPath.length()) {
618620
actualRootPath = path;
619621
}
620622
}
621-
if (rootDirResources == null & StringUtils.hasLength(commonPrefix)) {
623+
if (rootDirResources == null && StringUtils.hasLength(commonPrefix)) {
622624
// Try common parent directory as long as it points to the same classpath locations.
623625
rootDirResources = getResources(commonPrefix);
624626
Resource[] existingResources = this.rootDirCache.get(existingPath);
625627
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.
627630
this.rootDirCache.remove(existingPath);
628631
this.rootDirCache.put(commonPrefix, rootDirResources);
629632
actualRootPath = commonPrefix;

0 commit comments

Comments
 (0)