Skip to content

Commit 8ddbbc2

Browse files
committed
PathMatchingResourcePatternResolver's findPathMatchingResources needs to check for VFS before checking isJarResource
ResourceUtils isFileURL also detects "vfsfile" as a file system protocol (again). Issue: SPR-11887
1 parent 0a34f86 commit 8ddbbc2

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ protected Resource[] findPathMatchingResources(String locationPattern) throws IO
343343
Set<Resource> result = new LinkedHashSet<Resource>(16);
344344
for (Resource rootDirResource : rootDirResources) {
345345
rootDirResource = resolveRootDirResource(rootDirResource);
346-
if (isJarResource(rootDirResource)) {
347-
result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
348-
}
349-
else if (rootDirResource.getURL().getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
346+
if (rootDirResource.getURL().getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
350347
result.addAll(VfsResourceMatchingDelegate.findMatchingResources(rootDirResource, subPattern, getPathMatcher()));
351348
}
349+
else if (isJarResource(rootDirResource)) {
350+
result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
351+
}
352352
else {
353353
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
354354
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public abstract class ResourceUtils {
7272
/** URL protocol for an entry from a JBoss jar file: "vfszip" */
7373
public static final String URL_PROTOCOL_VFSZIP = "vfszip";
7474

75-
/** URL protocol for a JBoss VFS resource: "vfs" */
75+
/** URL protocol for a JBoss file system resource: "vfsfile" */
76+
public static final String URL_PROTOCOL_VFSFILE = "vfsfile";
77+
78+
/** URL protocol for a general JBoss VFS resource: "vfs" */
7679
public static final String URL_PROTOCOL_VFS = "vfs";
7780

7881
/** Separator between JAR URL and file path within the JAR */
@@ -248,27 +251,26 @@ public static File getFile(URI resourceUri, String description) throws FileNotFo
248251

249252
/**
250253
* Determine whether the given URL points to a resource in the file system,
251-
* that is, has protocol "file" or "vfs".
254+
* that is, has protocol "file", "vfsfile" or "vfs".
252255
* @param url the URL to check
253256
* @return whether the URL has been identified as a file system URL
254257
*/
255258
public static boolean isFileURL(URL url) {
256259
String protocol = url.getProtocol();
257-
return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFS.equals(protocol));
260+
return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFSFILE.equals(protocol) ||
261+
URL_PROTOCOL_VFS.equals(protocol));
258262
}
259263

260264
/**
261265
* Determine whether the given URL points to a resource in a jar file,
262-
* that is, has protocol "jar", "zip", "wsjar" or "code-source".
263-
* <p>"zip" and "wsjar" are used by WebLogic Server and WebSphere, respectively,
264-
* but can be treated like jar files.
266+
* that is, has protocol "jar", "zip", "vfszip" or "wsjar".
265267
* @param url the URL to check
266268
* @return whether the URL has been identified as a JAR URL
267269
*/
268270
public static boolean isJarURL(URL url) {
269271
String protocol = url.getProtocol();
270272
return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
271-
URL_PROTOCOL_WSJAR.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol));
273+
URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol));
272274
}
273275

274276
/**

0 commit comments

Comments
 (0)