Skip to content

Commit af59358

Browse files
huyachigegesbrannen
authored andcommitted
Avoid duplicate resources in PathMatchingResourcePatternResolver on Windows
This commit updates PathMatchingResourcePatternResolver to avoid returning duplicate resources on MS Windows when searching using the `classpath*:` prefix and a wildcard pattern that matches resources which are directly present in a JAR as well as present via classpath manifest entries. See gh-31598 Closes gh-31603 (cherry picked from commit d5874ab)
1 parent 75193b2 commit af59358

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ protected void addClassPathManifestEntries(Set<Resource> result) {
430430
int prefixIndex = filePath.indexOf(':');
431431
if (prefixIndex == 1) {
432432
// Possibly "c:" drive prefix on Windows, to be upper-cased for proper duplicate detection
433-
filePath = StringUtils.capitalize(filePath);
433+
// to resolve find duplicate jar resource on windows
434+
filePath = "/" + StringUtils.capitalize(filePath);
434435
}
435436
// # can appear in directories/filenames, java.net.URL should not treat it as a fragment
436437
filePath = StringUtils.replace(filePath, "#", "%23");

0 commit comments

Comments
 (0)