From dc4cda1b131acefa25869691efeac116fe377d32 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 23 Apr 2020 12:48:07 +0200 Subject: [PATCH] WARN against invalid patterns with PathPatternParser As of gh-24952, `PathPatternParser` will strictly reject patterns with `"**"` in the middle of them. `"**"` is only allowed at the end of the pattern for matching multiple path segments until the end of the path. Currently, if `"**"` is used in the middle of a pattern it will be considered as a single `"*"` instead. Rejecting such cases should clarify the situation. This commit prepares for that upcoming change and: * logs a warning message if such a case is used by an application * expands the MVC and WebFlux documentation about URI matching in general Closes gh-24958 --- .../web/util/pattern/PathPattern.java | 4 ++ .../web/util/pattern/PathPatternParser.java | 14 ++++++- .../util/pattern/PathPatternParserTests.java | 10 ++++- src/docs/asciidoc/web/webflux.adoc | 42 ++++++++++++++++--- src/docs/asciidoc/web/webmvc.adoc | 38 ++++++++++++++--- 5 files changed, 94 insertions(+), 14 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 9c1b6cfe73..84b409b168 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -47,6 +47,10 @@ import org.springframework.util.StringUtils; * and captures it as a variable named "spring" * * + * Notable behavior difference with {@code AntPathMatcher}:
+ * {@code **} and its capturing variant {*spring} cannot be used in the middle of a pattern + * string, only at the end: {@code /pages/{**}} is valid, but {@code /pages/{**}/details} is not. + * *

Examples

*