Apache Lucene open-source search software
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).
Uwe Schindler64bdf38619cf
diff --git a/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java b/lucene/src/java/org/apache/lucene/search/AutomatonQuery.javaindex d7796342a94..0d2d5ee2b20 100644--- a/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java+++ b/lucene/src/java/org/apache/lucene/search/AutomatonQuery.java@@ -75,7 +75,8 @@ public class AutomatonQuery extends MultiTermQuery {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);