Skip to content

Commit 899f235

Browse files
committed
Detect Tomcat's "war" protocol as jar URL
Issue: SPR-15332
1 parent 4e82bf3 commit 899f235

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,6 +63,9 @@ public abstract class ResourceUtils {
6363
/** URL protocol for an entry from a jar file: "jar" */
6464
public static final String URL_PROTOCOL_JAR = "jar";
6565

66+
/** URL protocol for an entry from a war file: "war" */
67+
public static final String URL_PROTOCOL_WAR = "war";
68+
6669
/** URL protocol for an entry from a zip file: "zip" */
6770
public static final String URL_PROTOCOL_ZIP = "zip";
6871

@@ -258,7 +261,7 @@ public static File getFile(URI resourceUri, String description) throws FileNotFo
258261

259262
/**
260263
* Determine whether the given URL points to a resource in the file system,
261-
* that is, has protocol "file", "vfsfile" or "vfs".
264+
* i.e. has protocol "file", "vfsfile" or "vfs".
262265
* @param url the URL to check
263266
* @return whether the URL has been identified as a file system URL
264267
*/
@@ -269,15 +272,16 @@ public static boolean isFileURL(URL url) {
269272
}
270273

271274
/**
272-
* Determine whether the given URL points to a resource in a jar file,
273-
* that is, has protocol "jar", "zip", "vfszip" or "wsjar".
275+
* Determine whether the given URL points to a resource in a jar file.
276+
* i.e. has protocol "jar", "war, ""zip", "vfszip" or "wsjar".
274277
* @param url the URL to check
275278
* @return whether the URL has been identified as a JAR URL
276279
*/
277280
public static boolean isJarURL(URL url) {
278281
String protocol = url.getProtocol();
279-
return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
280-
URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol));
282+
return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_WAR.equals(protocol) ||
283+
URL_PROTOCOL_ZIP.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol) ||
284+
URL_PROTOCOL_WSJAR.equals(protocol));
281285
}
282286

283287
/**

0 commit comments

Comments
 (0)