Skip to content

Commit c6deeb3

Browse files
committed
ResourceUtils.extractArchiveURL properly deals with top-level war URLs
Issue: SPR-15556 (cherry picked from commit 7b3f5fd)
1 parent f80b2d9 commit c6deeb3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spring-core/src/main/java/org/springframework/util/ResourceUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,11 @@ public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
341341

342342
int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
343343
if (endIndex != -1) {
344-
// Tomcat's "jar:war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
344+
// Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
345345
String warFile = urlFile.substring(0, endIndex);
346+
if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) {
347+
return new URL(warFile);
348+
}
346349
int startIndex = warFile.indexOf(WAR_URL_PREFIX);
347350
if (startIndex != -1) {
348351
return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
@@ -356,8 +359,6 @@ public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
356359
/**
357360
* Create a URI instance for the given URL,
358361
* replacing spaces with "%20" URI encoding first.
359-
* <p>Furthermore, this method works on JDK 1.4 as well,
360-
* in contrast to the {@code URL.toURI()} method.
361362
* @param url the URL to convert into a URI instance
362363
* @return the URI instance
363364
* @throws URISyntaxException if the URL wasn't a valid URI

0 commit comments

Comments
 (0)