mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Use JarFile#entries() instead of #stream() for consistent entry paths
Closes gh-35617
This commit is contained in:
+4
-9
@@ -41,7 +41,6 @@ import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableSet;
|
||||
@@ -937,14 +936,10 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
}
|
||||
Set<Resource> result = new LinkedHashSet<>(64);
|
||||
NavigableSet<String> entriesCache = new TreeSet<>();
|
||||
Iterator<String> entryIterator = jarFile.stream().map(JarEntry::getName).sorted().iterator();
|
||||
while (entryIterator.hasNext()) {
|
||||
String entryPath = entryIterator.next();
|
||||
int entrySeparatorIndex = entryPath.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
|
||||
if (entrySeparatorIndex >= 0) {
|
||||
entryPath = entryPath.substring(entrySeparatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length());
|
||||
}
|
||||
entriesCache.add(entryPath);
|
||||
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
|
||||
entriesCache.add(entries.nextElement().getName());
|
||||
}
|
||||
for (String entryPath : entriesCache) {
|
||||
if (entryPath.startsWith(rootEntryPath)) {
|
||||
String relativePath = entryPath.substring(rootEntryPath.length());
|
||||
if (getPathMatcher().match(subPattern, relativePath)) {
|
||||
|
||||
Reference in New Issue
Block a user