Skip to content

PathMatchingResourcePatternResolver wrongly assumes that target/classes always exists #34764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bbortt opened this issue Apr 15, 2025 · 0 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on type: regression A bug that is also a regression

Comments

@bbortt
Copy link

bbortt commented Apr 15, 2025

What I think is a bug has been introduced in [email protected].

The problem didn't occur in [email protected]. I did see some changes to PathMatchingResourcePatternResolver in the latest release, but fail to grasp how that would be related.

What is wrong in my opinion...

Assuming that a Maven project always has a target/classes folder present is wrong in my humble opinion. E.g. I personally like to create "integration test modules" for properly testing Spring autoconfigurations. These do only contain a target/test-classes folder.

More Context

The following fails now, and didn't before:

    public static void main(final String[] args) throws IOException {
        var resources = new PathMatchingResourcePatternResolver()
                .getResources("classpath*:**/*Test.xml");

        assertThat(resources)
                .hasSize(1);
    }

It produces the following stacktrace.

java.nio.file.NoSuchFileException: [REDACTED]\spring-core-bug-reproducer\integration-test\target\classes
    at sun.nio.fs.WindowsException.translateToIOException (WindowsException.java:85)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:103)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:108)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes (WindowsFileAttributeViews.java:53)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes (WindowsFileAttributeViews.java:38)
    at sun.nio.fs.WindowsFileSystemProvider.readAttributes (WindowsFileSystemProvider.java:197)
    at java.nio.file.Files.readAttributes (Files.java:1853)
    at java.util.zip.ZipFile$Source.get (ZipFile.java:1445)
    at java.util.zip.ZipFile$CleanableResource.<init> (ZipFile.java:724)
    at java.util.zip.ZipFile.<init> (ZipFile.java:251)
    at java.util.zip.ZipFile.<init> (ZipFile.java:180)
    at java.util.jar.JarFile.<init> (JarFile.java:345)
    at sun.net.www.protocol.jar.URLJarFile.<init> (URLJarFile.java:100)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile (URLJarFile.java:69)
    at sun.net.www.protocol.jar.JarFileFactory.get (JarFileFactory.java:177)
    at sun.net.www.protocol.jar.JarURLConnection.connect (JarURLConnection.java:109)
    at sun.net.www.protocol.jar.JarURLConnection.getJarFile (JarURLConnection.java:70)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources (PathMatchingResourcePatternResolver.java:844)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources (PathMatchingResourcePatternResolver.java:713)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources (PathMatchingResourcePatternResolver.java:351)
    at io.github.bbortt.spring.reproducer.ClassPathResolverTest.main (ClassPathResolverTest.java:13)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:375)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:364)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:286)
    at java.lang.Thread.run (Thread.java:1583)

Reproducer

There you go: https://github.com/bbortt/spring-core-34764-reproducer.

I would be open to help with solving the case, if someone can point me into a direction 😉 also, if you think that change in behavior is intended, please let me know!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 15, 2025
@bclozel bclozel added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) labels Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants