Revert ParsingPathMatcher concurrency checks
`PathPatternParser` is now thread-safe and creates a new internal parser for each `parse` call, since this operation is cheap. This commit removes the `ThreadLocal` based instances of `PathPatternParser` in `ParsingPathMatcher` which are not required anymore. Issue: SPR-15246
This commit is contained in:
@@ -43,8 +43,7 @@ public class ParsingPathMatcher implements PathMatcher {
|
||||
private final ConcurrentMap<String, PathPattern> cache =
|
||||
new ConcurrentHashMap<>(64);
|
||||
|
||||
private static final ThreadLocal<PathPatternParser> PARSER
|
||||
= ThreadLocal.withInitial(() -> new PathPatternParser());
|
||||
private final PathPatternParser parser = new PathPatternParser();
|
||||
|
||||
@Override
|
||||
public boolean match(String pattern, String path) {
|
||||
@@ -113,7 +112,7 @@ public class ParsingPathMatcher implements PathMatcher {
|
||||
private PathPattern getPathPattern(String pattern) {
|
||||
PathPattern pathPattern = this.cache.get(pattern);
|
||||
if (pathPattern == null) {
|
||||
pathPattern = PARSER.get().parse(pattern);
|
||||
pathPattern = this.parser.parse(pattern);
|
||||
this.cache.put(pattern, pathPattern);
|
||||
}
|
||||
return pathPattern;
|
||||
|
||||
@@ -63,9 +63,9 @@ public class PathPatternParser {
|
||||
* @param pathPattern the input path pattern, e.g. /foo/{bar}
|
||||
* @return a PathPattern for quickly matching paths against the specified path pattern
|
||||
*/
|
||||
public PathPattern parse(String pattern) {
|
||||
public PathPattern parse(String pathPattern) {
|
||||
InternalPathPatternParser ippp = new InternalPathPatternParser(separator, caseSensitive);
|
||||
return ippp.parse(pattern);
|
||||
return ippp.parse(pathPattern);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user