From 725b02a66d06fda2a49024412ce29b0e6b387382 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 23 Feb 2025 14:02:57 +0100 Subject: [PATCH] Ignore entries cache if no matching root entry path found Closes gh-34446 --- .../io/support/PathMatchingResourcePatternResolver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 e32e239cf8..127d457d9e 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 @@ -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; + } } }