Browse Source

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
pull/579/head
Juergen Hoeller 12 years ago
parent
commit
8ddbbc2e67
  1. 8
      spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java
  2. 16
      spring-core/src/main/java/org/springframework/util/ResourceUtils.java

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

@ -343,12 +343,12 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol @@ -343,12 +343,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));
}

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

@ -72,7 +72,10 @@ public abstract class ResourceUtils { @@ -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";
/** Separator between JAR URL and file path within the JAR */
@ -248,27 +251,26 @@ public abstract class ResourceUtils { @@ -248,27 +251,26 @@ 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".
* <p>"zip" and "wsjar" are used by WebLogic Server and WebSphere, respectively,
* but can be treated like jar files.
* that is, has protocol "jar", "zip", "vfszip" or "wsjar".
* @param url the URL to check
* @return whether the URL has been identified as a JAR URL
*/
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));
}
/**

Loading…
Cancel
Save