Browse Source

Ignore entries cache if no matching root entry path found

Closes gh-34446
pull/34656/head
Juergen Hoeller 10 months ago
parent
commit
725b02a66d
  1. 6
      spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

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

@ -816,17 +816,21 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol @@ -816,17 +816,21 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
// Clean root entry path to match jar entries format without "!" separators
rootEntryPath = rootEntryPath.replace(ResourceUtils.JAR_URL_SEPARATOR, "/");
// Search sorted entries from first entry with rootEntryPath prefix
boolean rootEntryPathFound = false;
for (String entryPath : entriesCache.tailSet(rootEntryPath, false)) {
if (!entryPath.startsWith(rootEntryPath)) {
// We are beyond the potential matches in the current TreeSet.
break;
}
rootEntryPathFound = true;
String relativePath = entryPath.substring(rootEntryPath.length());
if (getPathMatcher().match(subPattern, relativePath)) {
result.add(rootDirResource.createRelative(relativePath));
}
}
return result;
if (rootEntryPathFound) {
return result;
}
}
}

Loading…
Cancel
Save