Reject "/path/**/other" patterns in PathPatternParser
See original GitHub issueIssue:
Created 2 mappings as following in the controller, code is in Controller .javaof the attached project.
@GetMapping("/foo/**")
public ResponseEntity getFoo() {}
@GetMapping("/foo/**/bar")
public ResponseEntity getFooBar() {}
- In
webmvcwhenever request comes as/foo/1/2/3/bar(as far as last path segment isbar) it maps togetFooBar. - If
baris not specified ast last path segment then it maps togetFoo. i.e allfoo/1,foo/1/2,foo/ab/cd… maps togetFoo. - The issue is in webflux, when I switch to
webfluxall mappings map togetFoo. No matter if path consists ofbarin the last path segment. - For eg.
/foo/ab/cd/barmaps togetFooinstead ofgetFooBar.
Uploaded the project here , to switch between
webfluxandwebmvcplease comment out appropriate starter dependency inpom.xml.
Repro project here : https://github.com/kaladhar-mummadi/demo-issue
Notes:
- Webmvc AntPathMatcherTests has tests like
/bla/**/bla, which are not covered in PathPatternTests of WebFlux.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
PathPatternParser (Spring Framework 6.0.2 API)
Process the path pattern content, a character at a time, breaking it into path elements around separator boundaries and verifying the structure at...
Read more >How to apply the PathPatternParser introduced in Spring 5?
I am using Spring Boot 2.1.2 which uses Spring 5. However when I set up my controller method like this, the request doesn't...
Read more >Spring MVC URL Matching Improvements - Baeldung
Spring 5 brought a new PathPatternParser for parsing URI template patterns. This is an alternative to the previously used AntPathMatcher.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This won’t be a breaking change since we’ll support both
AntPathMatcherandPathPatternParserinfrastructures for Spring MVC, leaving the current one as the default. This just gives an extra choice for developers interested in optimal path matching performance (we’re getting quite a few requests about that).WebFlux was a completely new effort and we took that opportunity to revisit parts we wanted to improve. Aligning both MVC and WebFlux right away in Spring Framework 5.0 wouldn’t have been a wise choice since at that point we didn’t have much experience/feedback on running WebFlux applications in production.
As for adding that feature to
PathPatternParser, I don’t think we should do that for the reasons listed above. Even if WebFlux applications are less popular than MVC apps, I believe it’s the first time we’re getting an issue about this since 5.0 is out (in 2017).@bclozel - I see a recent ticket https://github.com/spring-projects/spring-framework/issues/24945 to align MVC towards using PathPatternParser. Won’t this be a breaking change ?
I wonder why there are different strategies used for WebFlux and MVC. Would have been better if the change remained consistent across both.