Skip to content

Commit 3a61460

Browse files
committed
Use JarFile#entries() instead of #stream() for consistent entry paths
Closes gh-35617
1 parent ee284f2 commit 3a61460

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import java.util.Collections;
4242
import java.util.Enumeration;
4343
import java.util.HashSet;
44-
import java.util.Iterator;
4544
import java.util.LinkedHashSet;
4645
import java.util.Map;
4746
import java.util.NavigableSet;
@@ -937,14 +936,10 @@ protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource,
937936
}
938937
Set<Resource> result = new LinkedHashSet<>(64);
939938
NavigableSet<String> entriesCache = new TreeSet<>();
940-
Iterator<String> entryIterator = jarFile.stream().map(JarEntry::getName).sorted().iterator();
941-
while (entryIterator.hasNext()) {
942-
String entryPath = entryIterator.next();
943-
int entrySeparatorIndex = entryPath.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
944-
if (entrySeparatorIndex >= 0) {
945-
entryPath = entryPath.substring(entrySeparatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length());
946-
}
947-
entriesCache.add(entryPath);
939+
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
940+
entriesCache.add(entries.nextElement().getName());
941+
}
942+
for (String entryPath : entriesCache) {
948943
if (entryPath.startsWith(rootEntryPath)) {
949944
String relativePath = entryPath.substring(rootEntryPath.length());
950945
if (getPathMatcher().match(subPattern, relativePath)) {

0 commit comments

Comments
 (0)