diff --git a/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index 642c3317d7b..b2886bdad6f 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -570,9 +570,19 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * @throws IOException if directory contents could not be retrieved */ protected Set retrieveMatchingFiles(File rootDir, String pattern) throws IOException { + if (!rootDir.exists()) { + // Silently skip non-existing directories. + if (logger.isDebugEnabled()) { + logger.debug("Skipping [" + rootDir.getAbsolutePath() + "] because it does not exist"); + } + return Collections.emptySet(); + } if (!rootDir.isDirectory()) { - throw new IllegalStateException( - "Resource path [" + rootDir.getAbsolutePath() + "] does not denote a directory"); + // Complain louder if it exists but is no directory. + if (logger.isWarnEnabled()) { + logger.warn("Skipping [" + rootDir.getAbsolutePath() + "] because it does not denote a directory"); + } + return Collections.emptySet(); } if (!rootDir.canRead()) { if (logger.isWarnEnabled()) {