From 8ddbbc2e67ef83e83765be0c5a3e4cd00bc0ab4e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 1 Jul 2014 11:54:16 +0200 Subject: [PATCH] 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 --- .../PathMatchingResourcePatternResolver.java | 8 ++++---- .../org/springframework/util/ResourceUtils.java | 16 +++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index 9118f62d78b..1f54f63845c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -343,12 +343,12 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol Set result = new LinkedHashSet(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)); } 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 54d07645b0a..855a8ca5279 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -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 { /** * 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". - *

"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)); } /**