Skip to content

Commit d43dfc7

Browse files
committed
Properly extract jar file from Tomcat war URL
Issue: SPR-15485
1 parent 4d86515 commit d43dfc7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,13 @@ protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource,
576576
// We'll also handle paths with and without leading "file:" prefix.
577577
String urlFile = rootDirURL.getFile();
578578
try {
579-
int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
579+
int separatorIndex = urlFile.indexOf(ResourceUtils.WAR_URL_SEPARATOR);
580+
if (separatorIndex == -1) {
581+
separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
582+
}
580583
if (separatorIndex != -1) {
581584
jarFileUrl = urlFile.substring(0, separatorIndex);
582-
rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length());
585+
rootEntryPath = urlFile.substring(separatorIndex + 2); // both separators are 2 chars
583586
jarFile = getJarFile(jarFileUrl);
584587
}
585588
else {

0 commit comments

Comments
 (0)