Defensively resolve JarFile from JarURLConnection
Closes gh-34216
This commit is contained in:
parent
0f26f42da7
commit
36fd82f32f
|
@ -834,11 +834,17 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||||
|
|
||||||
if (con instanceof JarURLConnection jarCon) {
|
if (con instanceof JarURLConnection jarCon) {
|
||||||
// Should usually be the case for traditional JAR files.
|
// Should usually be the case for traditional JAR files.
|
||||||
jarFile = jarCon.getJarFile();
|
try {
|
||||||
jarFileUrl = jarCon.getJarFileURL().toExternalForm();
|
jarFile = jarCon.getJarFile();
|
||||||
JarEntry jarEntry = jarCon.getJarEntry();
|
jarFileUrl = jarCon.getJarFileURL().toExternalForm();
|
||||||
rootEntryPath = (jarEntry != null ? jarEntry.getName() : "");
|
JarEntry jarEntry = jarCon.getJarEntry();
|
||||||
closeJarFile = !jarCon.getUseCaches();
|
rootEntryPath = (jarEntry != null ? jarEntry.getName() : "");
|
||||||
|
closeJarFile = !jarCon.getUseCaches();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException ex) {
|
||||||
|
// Happens in case of cached root directory without specific subdirectory present.
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// No JarURLConnection -> need to resort to URL file parsing.
|
// No JarURLConnection -> need to resort to URL file parsing.
|
||||||
|
|
Loading…
Reference in New Issue