Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Avoid infinite loop in TestFuzzyQuery.

Adrien Grandb6c5a8a0c1c6
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java
index 62e63eaa8c6..ebaf3c0095b 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java
@@ -510,8 +510,11 @@ public class TestFuzzyQuery extends LuceneTestCase {
@SuppressWarnings({"unchecked","rawtypes"})
public void testRandom() throws Exception {
- int numTerms = atLeast(100);
int digits = TestUtil.nextInt(random(), 2, 3);
+ // underestimated total number of unique terms that randomSimpleString
+ // maybe generate, it assumes all terms have a length of 7
+ int vocabularySize = digits << 7;
+ int numTerms = Math.min(atLeast(100), vocabularySize);
Set<String> terms = new HashSet<>();
while (terms.size() < numTerms) {
terms.add(randomSimpleString(digits));