The PathPatternParser will match the pattern "/{foo}" against the path "/". This is a regression: the AntPathMatcher will not match with the same parameters.
The rationale: path/URI template variables (i.e. patterns with curly braces) should be considered required, and not optional. In that sense, they cannot be considered the same as wildcard matches (i.e. "/*" should match the path "/", but "/{foo}" should not). If they would be optional, we could not resolve the @PathVariable parameters in a @RequestMapping method.
Two commits to fix this. When a single variable is used a particular PathElement subclass is built, optimized for that scenario. The first commit fixed this PathElement. It then occurred to me that when multiple variables are bound, a different PathElement subclass is built. The second commit fixes that other PathElement. Testcases added.
Arjen Poutsma opened SPR-15264 and commented
The
PathPatternParser
will match the pattern "/{foo}" against the path "/". This is a regression: theAntPathMatcher
will not match with the same parameters.The rationale: path/URI template variables (i.e. patterns with curly braces) should be considered required, and not optional. In that sense, they cannot be considered the same as wildcard matches (i.e. "/*" should match the path "/", but "/{foo}" should not). If they would be optional, we could not resolve the
@PathVariable
parameters in a@RequestMapping
method.Affects: 5.0 M5
Referenced from: commits d924538, f1653cc
1 votes, 3 watchers
The text was updated successfully, but these errors were encountered: