You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2010/08/19 12:44:35 UTC

svn commit: r987118 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java

Author: uschindler
Date: Thu Aug 19 10:44:35 2010
New Revision: 987118

URL: http://svn.apache.org/viewvc?rev=987118&view=rev
Log:
Make compileAutomaton synchronized, as it can break for queries that are shared constants (like a drop down list in a web interface that provides predefined query constraints. These types of queries are in most places somewhere predefined in your code and then used by different threads/servlets/whatever). As the three transient vars cannot be set atomically, a parallel running thread may see half of the fields assigned and will get NPE).

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java?rev=987118&r1=987117&r2=987118&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java Thu Aug 19 10:44:35 2010
@@ -75,7 +75,8 @@ public class AutomatonQuery extends Mult
     MinimizationOperations.minimize(automaton);
   }
 
-  private void compileAutomaton() {
+  private synchronized void compileAutomaton() {
+    // this method must be synchronized, as setting the three transient fields is not atomic:
     if (runAutomaton == null) {
       runAutomaton = new ByteRunAutomaton(automaton);
       isFinite = SpecialOperations.isFinite(automaton);