Throw exception for illegal PathMatch configurations

With the new `ParsingPathMatcher` implementation, new patterns are now
allowed, such as `"/foo/{*bar}". The `"{*bar}"` segment will capture
everything until the end of the given path. Adding other elements after
that segment is illegal and will throw exceptions.

One can configure on a `PathMatchConfigurer` various options like
`useTrailingSlashMatch` and `useSuffixPatternMatch`; those options, when
enabled, will try to append suffixes like `".*"` and `"/"` to existing
path patterns. In case of a "capture the rest" pattern segment, those
options won't be honored.

This is why this commit ensures that an exception is thrown at the start
of the application if an illegal configuration is applied to the
`PathMatchConfigurer`.

Issue: SPR-15303, SPR-15558
This commit is contained in:
Brian Clozel
2017-06-01 18:22:05 +02:00
parent 8ea54270e1
commit 0557404715
7 changed files with 133 additions and 2 deletions

View File

@@ -30,6 +30,10 @@ import org.springframework.util.PathMatcher;
* <p>Once parsed, {@link PathPattern}s are tailored for fast matching
* and quick comparison.
*
* <p>Calls this {@link PathMatcher} implementation can lead to
* {@link PatternParseException} if the provided patterns are
* illegal.
*
* @author Andy Clement
* @author Juergen Hoeller
* @since 5.0