Skip to content
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

PathMatchingResourcePatternResolver can no longer handle paths containing spaces and special characters #30031

Closed
whydoievenneedthis opened this issue Feb 25, 2023 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@whydoievenneedthis
Copy link

whydoievenneedthis commented Feb 25, 2023

Affects: spring-core : 6.0.5


When the spring application is in a directory that contains a space, it skips probably all @ComponentScan-based bean creations (I am sure it skips all @Configuration classes, and I suspect it also skips all @RestControllers as well, so it is a pretty safe bet to assume that it skips everything else as well):

2023-02-25 01:09:30.921 DEBUG [           main] o.s.c.i.s.PathMatchingResourcePatternResolver : 
Failed to complete search in directory 
[C:\My%20Projects\sample\build\classes\java\main\com\example] for files matching pattern 
[**/*.class]: java.nio.file.NoSuchFileException: 
C:\My%20Projects\sample\build\classes\java\main\com\example

Functionality was working fine with 6.0.4.

Also, log level either in the line above, or somewhere close by must be ERROR, not DEBUG.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 25, 2023
@wilkinsona
Copy link
Member

This is a regression introduced in dbf3609. See spring-projects/spring-boot#34379 for further details.

@sbrannen sbrannen added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 26, 2023
@sbrannen sbrannen added this to the 6.0.6 milestone Feb 26, 2023
@sbrannen
Copy link
Member

sbrannen commented Feb 26, 2023

Thanks for reporting the regression.

The cause for the regression is that java.net.URL.getPath() does not decode the path; whereas, java.net.URI.getPath() does decode the path.

Consequently, PathMatchingResourcePatternResolver.convertModuleSystemURI(URI) works as expected, but the recently modified PathMatchingResourcePatternResolver.convertClassLoaderURL(URL) does not.

We'll look into it and provide a fix in 6.0.6.

@sbrannen
Copy link
Member

Possible solution outlined by @JoeyBling in #29934 (comment).

@sbrannen sbrannen changed the title PathMatchingResourcePatternResolver cannot handle directory with space PathMatchingResourcePatternResolver can no longer handle paths containing spaces Feb 27, 2023
@123Haynes
Copy link

123Haynes commented Feb 27, 2023

This also happens if the path contains other chars like ## not only with spaces.
I ran into this because my application is named frontend##3.0.0.war so the tomcat manager recognizes the 3.0.0 as the version number.

@sbrannen sbrannen changed the title PathMatchingResourcePatternResolver can no longer handle paths containing spaces PathMatchingResourcePatternResolver can no longer handle paths containing spaces and special characters Feb 27, 2023
@sbrannen
Copy link
Member

This also happens if the path contains other chars like ## not only with spaces.

Yes, we are aware that it is a general decoding issue.

I've updated the title of this issue to reflect that.

Thanks for prompting that.

@jhoeller jhoeller self-assigned this Feb 28, 2023
mdeinum pushed a commit to mdeinum/spring-framework that referenced this issue Jun 29, 2023
Also raising the log level to warn for file system retrieval failures.

Closes spring-projectsgh-30031
mdeinum pushed a commit to mdeinum/spring-framework that referenced this issue Jun 29, 2023
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) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

6 participants