@@ -705,11 +705,13 @@ public boolean matches(char[] target, Match match) {
705705 */
706706 public boolean matches (char [] target , int start , int end , Match match ) {
707707
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+ }
713715 }
714716 Context con = this .context ;
715717 if (!con .claim ()) {
@@ -890,11 +892,13 @@ public boolean matches(String target, Match match) {
890892 */
891893 public boolean matches (String target , int start , int end , Match match ) {
892894
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+ }
898902 }
899903 Context con = this .context ;
900904 if (!con .claim ()) {
@@ -1570,11 +1574,13 @@ public boolean matches(CharacterIterator target, Match match) {
15701574
15711575
15721576
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+ }
15781584 }
15791585 Context con = this .context ;
15801586 if (!con .claim ()) {
@@ -1739,9 +1745,9 @@ else if (this.firstChar != null) {
17391745 boolean hasBackReferences = false ;
17401746
17411747 transient int minlength ;
1742- transient Op operations = null ;
1748+ transient volatile Op operations = null ;
17431749 transient int numberOfClosures ;
1744- transient Context context = null ;
1750+ transient volatile Context context = null ;
17451751 transient RangeToken firstChar = null ;
17461752
17471753 transient String fixedString = null ;
0 commit comments