Skip to content

Commit 643a68f

Browse files
committed
Detect existing jar URLs from URLClassLoader.getURLs()
Closes gh-22346
1 parent ac4525d commit 643a68f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -372,8 +372,9 @@ protected void addAllClassLoaderJarRoots(@Nullable ClassLoader classLoader, Set<
372372
try {
373373
for (URL url : ((URLClassLoader) classLoader).getURLs()) {
374374
try {
375-
UrlResource jarResource = new UrlResource(
376-
ResourceUtils.JAR_URL_PREFIX + url + ResourceUtils.JAR_URL_SEPARATOR);
375+
UrlResource jarResource = (ResourceUtils.URL_PROTOCOL_JAR.equals(url.getProtocol()) ?
376+
new UrlResource(url) :
377+
new UrlResource(ResourceUtils.JAR_URL_PREFIX + url + ResourceUtils.JAR_URL_SEPARATOR));
377378
if (jarResource.exists()) {
378379
result.add(jarResource);
379380
}

0 commit comments

Comments
 (0)