From b6c5a8a0c1c6b93b36a57921b06346b577251439 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 28 Feb 2017 11:53:50 +0100 Subject: [PATCH] Avoid infinite loop in TestFuzzyQuery. --- .../src/test/org/apache/lucene/search/TestFuzzyQuery.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 terms = new HashSet<>(); while (terms.size() < numTerms) { terms.add(randomSimpleString(digits));