Skip to content

Commit b3e94dc

Browse files
committed
PathMatchingResourcePatternResolver tries all root URLs (any file extension) as jar file
Issue: SPR-14936
1 parent 89802cf commit b3e94dc

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -365,19 +365,17 @@ protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource>
365365
if (classLoader instanceof URLClassLoader) {
366366
try {
367367
for (URL url : ((URLClassLoader) classLoader).getURLs()) {
368-
if (ResourceUtils.isJarFileURL(url)) {
369-
try {
370-
UrlResource jarResource = new UrlResource(
371-
ResourceUtils.JAR_URL_PREFIX + url.toString() + ResourceUtils.JAR_URL_SEPARATOR);
372-
if (jarResource.exists()) {
373-
result.add(jarResource);
374-
}
368+
try {
369+
UrlResource jarResource = new UrlResource(
370+
ResourceUtils.JAR_URL_PREFIX + url.toString() + ResourceUtils.JAR_URL_SEPARATOR);
371+
if (jarResource.exists()) {
372+
result.add(jarResource);
375373
}
376-
catch (MalformedURLException ex) {
377-
if (logger.isDebugEnabled()) {
378-
logger.debug("Cannot search for matching files underneath [" + url +
379-
"] because it cannot be converted to a valid 'jar:' URL: " + ex.getMessage());
380-
}
374+
}
375+
catch (MalformedURLException ex) {
376+
if (logger.isDebugEnabled()) {
377+
logger.debug("Cannot search for matching files underneath [" + url +
378+
"] because it cannot be converted to a valid 'jar:' URL: " + ex.getMessage());
381379
}
382380
}
383381
}
@@ -421,14 +419,12 @@ protected void addClassPathManifestEntries(Set<Resource> result) {
421419
for (String path : StringUtils.delimitedListToStringArray(
422420
javaClassPathProperty, System.getProperty("path.separator"))) {
423421
try {
424-
if (path.endsWith(ResourceUtils.JAR_FILE_EXTENSION)) {
425-
File file = new File(path);
426-
UrlResource jarResource = new UrlResource(ResourceUtils.JAR_URL_PREFIX +
427-
ResourceUtils.FILE_URL_PREFIX + file.getAbsolutePath() +
428-
ResourceUtils.JAR_URL_SEPARATOR);
429-
if (jarResource.exists()) {
430-
result.add(jarResource);
431-
}
422+
File file = new File(path);
423+
UrlResource jarResource = new UrlResource(ResourceUtils.JAR_URL_PREFIX +
424+
ResourceUtils.FILE_URL_PREFIX + file.getAbsolutePath() +
425+
ResourceUtils.JAR_URL_SEPARATOR);
426+
if (jarResource.exists()) {
427+
result.add(jarResource);
432428
}
433429
}
434430
catch (MalformedURLException ex) {

0 commit comments

Comments
 (0)