protected Set<File> retrieveMatchingFiles(File rootDir, String pattern) throws IOException {
        if (!rootDir.exists()) {
            // Silently skip non-existing directories.
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Skipping [{}] because it does not exist", rootDir.getAbsolutePath());
            }
            return Collections.emptySet();
        }
        if (!rootDir.isDirectory()) {
            // Complain louder if it exists but is no directory.
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("Skipping [{}] because it does not denote a directory", rootDir.getAbsolutePath());
            }
            return Collections.emptySet();
        }
        if (!rootDir.canRead()) {
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("Skipping search for matching files underneath directory [{}] because the application is not allowed to read the directory", rootDir.getAbsolutePath());
            }
            return Collections.emptySet();
        }
        String fullPattern = StringUtils.replace(rootDir.getAbsolutePath(), File.separator, "/");
        if (!pattern.startsWith("/")) {
            fullPattern += "/";
        }
        fullPattern = fullPattern + StringUtils.replace(pattern, File.separator, "/");
        Set<File> result = new LinkedHashSet<>(8);
        doRetrieveMatchingFiles(fullPattern, rootDir, result);
        return result;
    }
Retrieve files that match the given path pattern,
checking the given directory and its subdirectories.

@param rootDir the directory to start from
@param pattern the pattern to match against,
               relative to the root directory
@return a mutable Set of matching Resource instances
@throws IOException if directory contents could not be retrieved
analyzer/src/main/java/nl/basjes/parse/useragent/utils/springframework/core/io/support/PathMatchingResourcePatternResolver.java