-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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 handles path names differently than Spring 5 on Mac OS #29243
Comments
Thanks for reporting this @kazuki43zoo this is probably linked to #29163 |
Note: Occurred on Mac OS and Windows OS. Linux OS works fine. |
Windows OS is another error. Probably it's same with #29226. |
Hi @kazuki43zoo, Thanks for bringing this to our attention. My initial analysis shows that there are two issues here.
You can address # 1 by accessing the URL-decoded path via the path = resource.getURI().getPath().replaceFirst(".*/test-classes/", ""); As stated in the Javadoc for You can address # 2 by normalizing the path using path = Normalizer.normalize(path, Normalizer.Form.NFC); Please let us know if those modifications to your test allow the test to pass. In addition, I will investigate if we can align with the behavior in Spring Framework 5.3.x. |
This commit introduces tests which serve as "regression tests" for the behavior of PathMatchingResourcePatternResolver in Spring Framework 5.3.x with regard to URL-encoding and Unicode normalization of resource paths. Specifically, the new tests demonstrate that resource paths do NOT need to be decoded or normalized in 5.3.x. See gh-29243
This commit introduces tests which serve as "regression tests" for the behavior of PathMatchingResourcePatternResolver in Spring Framework 5.3.x with regard to URL-encoding and Unicode normalization of resource paths. Specifically, the new tests demonstrate that resource paths do NOT need to be decoded or normalized in 5.3.x. See spring-projectsgh-29243
Team Decision: After further consideration, we have decided that the use of Instead, if you wish to perform a direct comparison against a path in a For example, if you change your original code to the following your tests should pass. path = resource.getFile().getAbsolutePath().replaceFirst(".*/test-classes/", ""); In light of the above, we are closing this issue. |
As a side note, if you still need to normalize paths you might find that your assertion library provides such support. For example, AssertJ provides |
This commit introduces assertions that verify that the sub-path is properly URL-decoded when a path contains `#`. The additional assertions are necessary since the existing assertions use Resource#getFilename which already implicitly decodes the path. See gh-29243
See inline comments in commit for details. See gh-29243
@sbrannen Thanks for good advice!! |
I was applied a latest Spring 6 snapshot version, I found the
PathMatchingResourcePatternResolver
handles path names differently than Spring 5 latest GA version(5.3.23) on Mac OS.For example, If the file name contains voiced sound characters (e.g.
バ
), the result will be different.Is this behavior by design or a regression bug as implemented in Spring 6? If this behavior was designed, I will rewrite my library to adjust Spring 6 specification.
Reproducing
Directory structures:
Test Cases:
Repro project
https://github.com/kazuki43zoo/repro-spring-project-gh-29243
How to run with Spring 5 GA version:
How to run with Spring 6 snapshot version:
The text was updated successfully, but these errors were encountered: