From bbb593db48e04c99fd4c739c5cd9f010eb4159e9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2025 19:18:30 +0100 Subject: [PATCH] Consistently ignore non-jar files in classpath Closes gh-34417 --- .../core/io/support/PathMatchingResourcePatternResolver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 0728257ddb35..e32e239cf835 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 @@ -843,8 +843,9 @@ protected Set doFindPathMatchingJarResources(Resource rootDirResource, rootEntryPath = (jarEntry != null ? jarEntry.getName() : ""); closeJarFile = !jarCon.getUseCaches(); } - catch (FileNotFoundException ex) { - // Happens in case of cached root directory without specific subdirectory present. + catch (ZipException | FileNotFoundException ex) { + // Happens in case of a non-jar file or in case of a cached root directory + // without specific subdirectory present, respectively. return Collections.emptySet(); } }