Skip to content

Apache Lucene open-source search software

LUCENE-10010: fix TestMockAnalyzer to determinize

Robert Muira39337e595c3
diff --git a/lucene/test-framework/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java b/lucene/test-framework/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
index a6d047084e6..b8eb3738460 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
@@ -35,6 +35,7 @@ import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.automaton.Automata;
+import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.Operations;
@@ -221,8 +222,11 @@ public class TestMockAnalyzer extends BaseTokenStreamTestCase {
public void testRandomRegexps() throws Exception {
int iters = TEST_NIGHTLY ? atLeast(30) : atLeast(1);
for (int i = 0; i < iters; i++) {
- final CharacterRunAutomaton dfa =
- new CharacterRunAutomaton(AutomatonTestUtil.randomAutomaton(random()));
+ Automaton automaton =
+ Operations.determinize(
+ AutomatonTestUtil.randomAutomaton(random()),
+ Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);
+ final CharacterRunAutomaton dfa = new CharacterRunAutomaton(automaton);
final boolean lowercase = random().nextBoolean();
final int limit = TestUtil.nextInt(random(), 0, 500);
Analyzer a =