diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java index 7ca00f4ff7f..d8154f46ac6 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java @@ -704,11 +704,13 @@ public boolean matches(char[] target, Match match) { */ public boolean matches(char[] target, int start, int end, Match match) { - synchronized (this) { - if (this.operations == null) - this.prepare(); - if (this.context == null) - this.context = new Context(); + if (this.operations == null || this.context == null) { + synchronized (this) { + if (this.operations == null) + this.prepare(); + if (this.context == null) + this.context = new Context(); + } } Context con = null; synchronized (this.context) { @@ -889,11 +891,13 @@ public boolean matches(String target, Match match) { */ public boolean matches(String target, int start, int end, Match match) { - synchronized (this) { - if (this.operations == null) - this.prepare(); - if (this.context == null) - this.context = new Context(); + if (this.operations == null || this.context == null) { + synchronized (this) { + if (this.operations == null) + this.prepare(); + if (this.context == null) + this.context = new Context(); + } } Context con = null; synchronized (this.context) { @@ -1569,11 +1573,13 @@ public boolean matches(CharacterIterator target, Match match) { - synchronized (this) { - if (this.operations == null) - this.prepare(); - if (this.context == null) - this.context = new Context(); + if (this.operations == null || this.context == null) { + synchronized (this) { + if (this.operations == null) + this.prepare(); + if (this.context == null) + this.context = new Context(); + } } Context con = null; synchronized (this.context) { @@ -1738,9 +1744,9 @@ else if (this.firstChar != null) { boolean hasBackReferences = false; transient int minlength; - transient Op operations = null; + transient volatile Op operations = null; transient int numberOfClosures; - transient Context context = null; + transient volatile Context context = null; transient RangeToken firstChar = null; transient String fixedString = null;