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:
Brian Clozel
2017-02-21 11:42:31 +01:00
parent a0505bf1e7
commit babd5517aa
2 changed files with 4 additions and 5 deletions

View File

@@ -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;

View File

@@ -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);
}
}