@@ -705,11 +705,13 @@ public boolean matches(char[] target, Match match) {
705
705
*/
706
706
public boolean matches (char [] target , int start , int end , Match match ) {
707
707
708
- synchronized (this ) {
709
- if (this .operations == null )
710
- this .prepare ();
711
- if (this .context == null )
712
- this .context = new Context ();
708
+ if (this .operations == null || this .context == null ) {
709
+ synchronized (this ) {
710
+ if (this .operations == null )
711
+ this .prepare ();
712
+ if (this .context == null )
713
+ this .context = new Context ();
714
+ }
713
715
}
714
716
Context con = this .context ;
715
717
if (!con .claim ()) {
@@ -890,11 +892,13 @@ public boolean matches(String target, Match match) {
890
892
*/
891
893
public boolean matches (String target , int start , int end , Match match ) {
892
894
893
- synchronized (this ) {
894
- if (this .operations == null )
895
- this .prepare ();
896
- if (this .context == null )
897
- this .context = new Context ();
895
+ if (this .operations == null || this .context == null ) {
896
+ synchronized (this ) {
897
+ if (this .operations == null )
898
+ this .prepare ();
899
+ if (this .context == null )
900
+ this .context = new Context ();
901
+ }
898
902
}
899
903
Context con = this .context ;
900
904
if (!con .claim ()) {
@@ -1570,11 +1574,13 @@ public boolean matches(CharacterIterator target, Match match) {
1570
1574
1571
1575
1572
1576
1573
- synchronized (this ) {
1574
- if (this .operations == null )
1575
- this .prepare ();
1576
- if (this .context == null )
1577
- this .context = new Context ();
1577
+ if (this .operations == null || this .context == null ) {
1578
+ synchronized (this ) {
1579
+ if (this .operations == null )
1580
+ this .prepare ();
1581
+ if (this .context == null )
1582
+ this .context = new Context ();
1583
+ }
1578
1584
}
1579
1585
Context con = this .context ;
1580
1586
if (!con .claim ()) {
@@ -1739,9 +1745,9 @@ else if (this.firstChar != null) {
1739
1745
boolean hasBackReferences = false ;
1740
1746
1741
1747
transient int minlength ;
1742
- transient Op operations = null ;
1748
+ transient volatile Op operations = null ;
1743
1749
transient int numberOfClosures ;
1744
- transient Context context = null ;
1750
+ transient volatile Context context = null ;
1745
1751
transient RangeToken firstChar = null ;
1746
1752
1747
1753
transient String fixedString = null ;
0 commit comments