8309515: Stale cached data from Matcher.namedGroups() after Matcher.usePattern()

Reviewed-by: rriggs
This commit is contained in:
Raffaello Giulietti 2023-06-07 21:39:53 +00:00
parent ea41907396
commit 90027ff204
2 changed files with 24 additions and 1 deletions

View file

@ -390,6 +390,7 @@ public final class Matcher implements MatchResult {
if (newPattern == null)
throw new IllegalArgumentException("Pattern cannot be null");
parentPattern = newPattern;
namedGroups = null;
// Reallocate state storage
int parentGroupCount = Math.max(newPattern.capturingGroupCount, 10);