Skip to content

Commit 6f11d32

Browse files
rgithubliPaul Hohensee
authored andcommitted
8346142: [perf] scalability issue for the specjvm2008::xml.validation workload
Backport-of: 10d08dbc81aa14499410f0a7a64d0b3243b660f1
1 parent 0ec4708 commit 6f11d32

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,13 @@ public boolean matches(char[] target, Match match) {
704704
*/
705705
public boolean matches(char[] target, int start, int end, Match match) {
706706

707-
synchronized (this) {
708-
if (this.operations == null)
709-
this.prepare();
710-
if (this.context == null)
711-
this.context = new Context();
707+
if (this.operations == null || this.context == null) {
708+
synchronized (this) {
709+
if (this.operations == null)
710+
this.prepare();
711+
if (this.context == null)
712+
this.context = new Context();
713+
}
712714
}
713715
Context con = null;
714716
synchronized (this.context) {
@@ -889,11 +891,13 @@ public boolean matches(String target, Match match) {
889891
*/
890892
public boolean matches(String target, int start, int end, Match match) {
891893

892-
synchronized (this) {
893-
if (this.operations == null)
894-
this.prepare();
895-
if (this.context == null)
896-
this.context = new Context();
894+
if (this.operations == null || this.context == null) {
895+
synchronized (this) {
896+
if (this.operations == null)
897+
this.prepare();
898+
if (this.context == null)
899+
this.context = new Context();
900+
}
897901
}
898902
Context con = null;
899903
synchronized (this.context) {
@@ -1569,11 +1573,13 @@ public boolean matches(CharacterIterator target, Match match) {
15691573

15701574

15711575

1572-
synchronized (this) {
1573-
if (this.operations == null)
1574-
this.prepare();
1575-
if (this.context == null)
1576-
this.context = new Context();
1576+
if (this.operations == null || this.context == null) {
1577+
synchronized (this) {
1578+
if (this.operations == null)
1579+
this.prepare();
1580+
if (this.context == null)
1581+
this.context = new Context();
1582+
}
15771583
}
15781584
Context con = null;
15791585
synchronized (this.context) {
@@ -1738,9 +1744,9 @@ else if (this.firstChar != null) {
17381744
boolean hasBackReferences = false;
17391745

17401746
transient int minlength;
1741-
transient Op operations = null;
1747+
transient volatile Op operations = null;
17421748
transient int numberOfClosures;
1743-
transient Context context = null;
1749+
transient volatile Context context = null;
17441750
transient RangeToken firstChar = null;
17451751

17461752
transient String fixedString = null;

0 commit comments

Comments
 (0)