From 541d00366c30fafec33468b059495db236fba06a Mon Sep 17 00:00:00 2001 From: Tejas Date: Fri, 17 Apr 2026 21:16:27 -0400 Subject: [PATCH] Synchronized block locks on a mutable field --- .../impl/xpath/regex/RegularExpression.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/composite-builds/build-deps/jaxp/src/main/java/jaxp/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java b/composite-builds/build-deps/jaxp/src/main/java/jaxp/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java index 926b78a57d..779729ac6a 100644 --- a/composite-builds/build-deps/jaxp/src/main/java/jaxp/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java +++ b/composite-builds/build-deps/jaxp/src/main/java/jaxp/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java @@ -722,15 +722,17 @@ public boolean matches(char[] target, Match match) { */ public boolean matches(char[] target, int start, int end, Match match) { + Context ctx; synchronized (this) { if (this.operations == null) this.prepare(); if (this.context == null) this.context = new Context(); + ctx = this.context; } Context con = null; - synchronized (this.context) { - con = this.context.inuse ? new Context() : this.context; + synchronized (ctx) { + con = ctx.inuse ? new Context() : ctx; con.reset(target, start, end, this.numberOfClosures); } if (match != null) { @@ -907,15 +909,17 @@ public boolean matches(String target, Match match) { */ public boolean matches(String target, int start, int end, Match match) { + Context ctx; synchronized (this) { if (this.operations == null) this.prepare(); if (this.context == null) this.context = new Context(); + ctx = this.context; } Context con = null; - synchronized (this.context) { - con = this.context.inuse ? new Context() : this.context; + synchronized (ctx) { + con = ctx.inuse ? new Context() : ctx; con.reset(target, start, end, this.numberOfClosures); } if (match != null) { @@ -1586,15 +1590,17 @@ public boolean matches(CharacterIterator target, Match match) { + Context ctx; synchronized (this) { if (this.operations == null) this.prepare(); if (this.context == null) this.context = new Context(); + ctx = this.context; } Context con = null; - synchronized (this.context) { - con = this.context.inuse ? new Context() : this.context; + synchronized (ctx) { + con = ctx.inuse ? new Context() : ctx; con.reset(target, start, end, this.numberOfClosures); } if (match != null) {