Avoid infinite loop in TestFuzzyQuery.

This commit is contained in:
Adrien Grand 2017-02-28 11:53:50 +01:00
parent 04ba9968c0
commit b6c5a8a0c1
1 changed files with 4 additions and 1 deletions

View File

@ -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));