Skip to content

Commit

Permalink
Avoid duplicate resources in PathMatchingResourcePatternResolver on W…
Browse files Browse the repository at this point in the history
…indows

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)
  • Loading branch information
huyachigege authored and sbrannen committed Nov 14, 2023
1 parent 75193b2 commit af59358
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ protected void addClassPathManifestEntries(Set<Resource> result) {
int prefixIndex = filePath.indexOf(':');
if (prefixIndex == 1) {
// Possibly "c:" drive prefix on Windows, to be upper-cased for proper duplicate detection
filePath = StringUtils.capitalize(filePath);
// to resolve find duplicate jar resource on windows
filePath = "/" + StringUtils.capitalize(filePath);
}
// # can appear in directories/filenames, java.net.URL should not treat it as a fragment
filePath = StringUtils.replace(filePath, "#", "%23");
Expand Down

0 comments on commit af59358

Please sign in to comment.