Synchronise PathPatternParser access

This commit adds a synchronized block around the PathPatternParser,
since it is not thread-safe.
This commit is contained in:
Arjen Poutsma 2017-02-14 12:10:00 +01:00
parent a3561168b0
commit fcaf42507a
1 changed files with 6 additions and 2 deletions

View File

@ -77,7 +77,7 @@ public abstract class RequestPredicates {
*/
public static RequestPredicate path(String pattern) {
Assert.notNull(pattern, "'pattern' must not be null");
return new PathPatternPredicate(DEFAULT_PATTERN_PARSER.parse(pattern));
return pathPredicates(DEFAULT_PATTERN_PARSER).apply(pattern);
}
/**
@ -91,7 +91,11 @@ public abstract class RequestPredicates {
*/
public static Function<String, RequestPredicate> pathPredicates(PathPatternParser patternParser) {
Assert.notNull(patternParser, "'patternParser' must not be null");
return pattern -> new PathPatternPredicate(patternParser.parse(pattern));
return pattern -> {
synchronized (patternParser) {
return new PathPatternPredicate(patternParser.parse(pattern));
}
};
}
/**