There is problem with latest changes on the method PathMatchingResourcePatternResolver.doFindPathMatchingFileResources. It fails on Windows with the following error:

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/TestDir/target/classes/com/example
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
        at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:765)
        at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:91)
        at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:558)
        at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:328)

The leading slash should be removed before calling Path rootPath = fileSystem.getPath(rootDir); We cannot run any application on SB 3.0.0-SNAPSHOT on Windows because of this problem. Example of code raising the exception (after removing the leading slash it works fine):

FileSystem fileSystem = FileSystems.getDefault();
fileSystem.getPath("/C:/TestDir");

Comment From: sbrannen

Caused by:

  • 29163

Comment From: eugeniace

To solve the bug the following code from method protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) :

                URI rootDirUri;
        String rootDir;
        try {
            rootDirUri = rootDirResource.getURI();
                        rootDir = rootDirUri.getPath();
            // If the URI is for a "resource" in the GraalVM native image file system, we have to
            // ensure that the root directory does not end in a slash while simultaneously ensuring
            // that the root directory is not an empty string (since fileSystem.getPath("").resolve(str)
            // throws an ArrayIndexOutOfBoundsException in a native image).
            if ("resource".equals(rootDirUri.getScheme()) && (rootDir.length() > 1) && rootDir.endsWith("/")) {
                rootDir = rootDir.substring(0, rootDir.length() - 1);
            }
        }
        catch (Exception ex) {
            if (logger.isInfoEnabled()) {
                logger.info("Failed to resolve %s in the file system: %s".formatted(rootDirResource, ex));
            }
            return Collections.emptySet();
        }
                FileSystem fileSystem = getFileSystem(rootDirUri);
        if (fileSystem == null) {
            return Collections.emptySet();
        }
        try {
            Path rootPath = fileSystem.getPath(rootDir);

could be replaced with the following:

Path.of(rootDirResource.getURI()) . It also removes the ending /.

Comment From: sbrannen

Although this was technically a regression, that regression was not released.

In light of that, I have changed the label to task so that this issue does not show up in the release notes.