question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reject "/path/**/other" patterns in PathPatternParser

See original GitHub issue

Issue:

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 webmvc whenever request comes as /foo/1/2/3/bar (as far as last path segment is bar) it maps to getFooBar.
  • If bar is not specified ast last path segment then it maps to getFoo. i.e all foo/1, foo/1/2, foo/ab/cd… maps to getFoo.
  • The issue is in webflux, when I switch to webflux all mappings map to getFoo. No matter if path consists of bar in the last path segment.
  • For eg. /foo/ab/cd/bar maps to getFoo instead of getFooBar.

Uploaded the project here , to switch between webflux and webmvc please comment out appropriate starter dependency in pom.xml.

Repro project here : https://github.com/kaladhar-mummadi/demo-issue

Notes:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bclozelcommented, Apr 21, 2020

I see a recent ticket #24945 to align MVC towards using PathPatternParser. Won’t this be a breaking change ?

This won’t be a breaking change since we’ll support both AntPathMatcher and PathPatternParser infrastructures 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).

I wonder why there are different strategies used for WebFlux and MVC. Would have been better if the change remained consistent across both.

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).

1reaction
ranarulacommented, Apr 21, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found