PathPatternRouteMatcher should use custom separator

Prior to this commit, the `PathPatternRouteMatcher` would always use the
default path pattern separator when parsing incoming route strings to
`RouteMatcher.Route` instances.
When the `PathPatternRouteMatcher` is configured with a
`PathPatternParser` that has a custom separator (e.g., `.`), then the
matching algorithm can't match routes against parsed patterns.

This commit ensures that the route matcher uses the configured separator
at all times.

Fixes gh-23167
This commit is contained in:
Brian Clozel
2019-06-20 20:23:04 +02:00
parent f56c54dfc8
commit 5787fc16fb
2 changed files with 53 additions and 1 deletions

View File

@@ -36,18 +36,21 @@ public class PathPatternRouteMatcher implements RouteMatcher {
private final PathPatternParser parser;
private final String separator;
private final Map<String, PathPattern> pathPatternCache = new ConcurrentHashMap<>();
public PathPatternRouteMatcher(PathPatternParser parser) {
Assert.notNull(parser, "PathPatternParser must not be null");
this.parser = parser;
this.separator = String.valueOf(parser.getSeparator());
}
@Override
public Route parseRoute(String routeValue) {
return new PathContainerRoute(PathContainer.parsePath(routeValue));
return new PathContainerRoute(PathContainer.parsePath(routeValue, this.separator));
}
@Override