From 7b3f5fd855fe822ef1bfb21c3fa0d430c0713e39 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 17 May 2017 14:22:43 +0200 Subject: [PATCH] ResourceUtils.extractArchiveURL properly deals with top-level war URLs Issue: SPR-15556 --- .../main/java/org/springframework/util/ResourceUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java index b0a2b66e83b..46f704e4a10 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -341,8 +341,11 @@ public abstract class ResourceUtils { int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR); if (endIndex != -1) { - // Tomcat's "jar:war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt" + // Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt" String warFile = urlFile.substring(0, endIndex); + if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) { + return new URL(warFile); + } int startIndex = warFile.indexOf(WAR_URL_PREFIX); if (startIndex != -1) { return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length())); @@ -356,8 +359,6 @@ public abstract class ResourceUtils { /** * Create a URI instance for the given URL, * replacing spaces with "%20" URI encoding first. - *

Furthermore, this method works on JDK 1.4 as well, - * in contrast to the {@code URL.toURI()} method. * @param url the URL to convert into a URI instance * @return the URI instance * @throws URISyntaxException if the URL wasn't a valid URI