Apache Lucene open-source search software
fix TestAutomaton.testRandomFinite test bug that was trying to StringsToAutomaton.build a Collection of BytesRefs containing a too-massive (> 1000 UTF-8 bytes) term; corrected the exception message to make it clear the limit is in UTF-8 bytes, not java (UTF-16) characters
Mike McCandless11436a848cbc
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/StringsToAutomaton.java b/lucene/core/src/java/org/apache/lucene/util/automaton/StringsToAutomaton.javaindex 6c66dc6fd9e..3cfe945789e 100644--- a/lucene/core/src/java/org/apache/lucene/util/automaton/StringsToAutomaton.java+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/StringsToAutomaton.java@@ -269,7 +269,7 @@ final class StringsToAutomaton {throw new IllegalArgumentException("This builder doesn't allow terms that are larger than "+ Automata.MAX_STRING_UNION_TERM_LENGTH- + " characters, got "+ + " UTF-8 bytes, got "+ current);}assert stateRegistry != null : "Automaton already built.";diff --git a/lucene/core/src/test/org/apache/lucene/util/automaton/TestAutomaton.java b/lucene/core/src/test/org/apache/lucene/util/automaton/TestAutomaton.javaindex 6abe0aaff08..e4dd739ef78 100644--- a/lucene/core/src/test/org/apache/lucene/util/automaton/TestAutomaton.java+++ b/lucene/core/src/test/org/apache/lucene/util/automaton/TestAutomaton.java@@ -790,9 +790,18 @@ public class TestAutomaton extends LuceneTestCase {return null;}+ private static boolean hasMassiveTerm(Collection<BytesRef> terms) {+ for (BytesRef term : terms) {+ if (term.length > Automata.MAX_STRING_UNION_TERM_LENGTH) {+ return true;+ }+ }+ return false;+ }+private Automaton unionTerms(Collection<BytesRef> terms) {Automaton a;- if (random().nextBoolean()) {+ if (random().nextBoolean() || hasMassiveTerm(terms)) {if (VERBOSE) {System.out.println("TEST: unionTerms: use union");}diff --git a/lucene/core/src/test/org/apache/lucene/util/automaton/TestStringsToAutomaton.java b/lucene/core/src/test/org/apache/lucene/util/automaton/TestStringsToAutomaton.javaindex f093623c370..0e5a3f9fc30 100644--- a/lucene/core/src/test/org/apache/lucene/util/automaton/TestStringsToAutomaton.java+++ b/lucene/core/src/test/org/apache/lucene/util/automaton/TestStringsToAutomaton.java@@ -103,7 +103,7 @@ public class TestStringsToAutomaton extends LuceneTestCase {.startsWith("This builder doesn't allow terms that are larger than "+ Automata.MAX_STRING_UNION_TERM_LENGTH- + " characters"));+ + " UTF-8 bytes"));byte[] b1k = ArrayUtil.copyOfSubArray(b10k, 0, 1000);build(Collections.singleton(new BytesRef(b1k)), false); // no exception