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
(cherry picked from commit 8ddbbc2)
This commit is contained in:
Juergen Hoeller
2014-07-01 11:54:16 +02:00
parent 5b4748d897
commit 1ca0351831
2 changed files with 13 additions and 9 deletions

View File

@@ -340,12 +340,12 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
Set<Resource> result = new LinkedHashSet<Resource>(16);
for (Resource rootDirResource : rootDirResources) {
rootDirResource = resolveRootDirResource(rootDirResource);
if (isJarResource(rootDirResource)) {
result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
}
else if (rootDirResource.getURL().getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
if (rootDirResource.getURL().getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
result.addAll(VfsResourceMatchingDelegate.findMatchingResources(rootDirResource, subPattern, getPathMatcher()));
}
else if (isJarResource(rootDirResource)) {
result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
}
else {
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
}

View File

@@ -72,7 +72,10 @@ public abstract class ResourceUtils {
/** URL protocol for an entry from a JBoss jar file: "vfszip" */
public static final String URL_PROTOCOL_VFSZIP = "vfszip";
/** URL protocol for a JBoss VFS resource: "vfs" */
/** URL protocol for a JBoss file system resource: "vfsfile" */
public static final String URL_PROTOCOL_VFSFILE = "vfsfile";
/** URL protocol for a general JBoss VFS resource: "vfs" */
public static final String URL_PROTOCOL_VFS = "vfs";
/** URL protocol for an entry from an OC4J jar file: "code-source" */
@@ -251,18 +254,19 @@ public abstract class ResourceUtils {
/**
* Determine whether the given URL points to a resource in the file system,
* that is, has protocol "file" or "vfs".
* that is, has protocol "file", "vfsfile" or "vfs".
* @param url the URL to check
* @return whether the URL has been identified as a file system URL
*/
public static boolean isFileURL(URL url) {
String protocol = url.getProtocol();
return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFS.equals(protocol));
return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFSFILE.equals(protocol) ||
URL_PROTOCOL_VFS.equals(protocol));
}
/**
* Determine whether the given URL points to a resource in a jar file,
* that is, has protocol "jar", "zip", "wsjar" or "code-source".
* that is, has protocol "jar", "zip", "vfszip", "wsjar" or "code-source".
* <p>"zip" and "wsjar" are used by WebLogic Server and WebSphere, respectively,
* but can be treated like jar files. The same applies to "code-source" URLs on
* OC4J, provided that the path contains a jar separator.
@@ -272,7 +276,7 @@ public abstract class ResourceUtils {
public static boolean isJarURL(URL url) {
String protocol = url.getProtocol();
return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
URL_PROTOCOL_WSJAR.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol) ||
URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol) ||
(URL_PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(JAR_URL_SEPARATOR)));
}