LUCENE-7854: restore the IllegalArgumentException if you index too many tokens in one field

This commit is contained in:
Mike McCandless 2017-06-07 15:43:56 -04:00
parent bcce49c160
commit 6c3ece2b9f
2 changed files with 6 additions and 2 deletions

View File

@ -770,7 +770,11 @@ final class DefaultIndexingChain extends DocConsumer {
}
invertState.lastStartOffset = startOffset;
invertState.length = Math.addExact(invertState.length, invertState.termFreqAttribute.getTermFrequency());
try {
invertState.length = Math.addExact(invertState.length, invertState.termFreqAttribute.getTermFrequency());
} catch (ArithmeticException ae) {
throw new IllegalArgumentException("too many tokens for field \"" + field.name() + "\"");
}
//System.out.println(" term=" + invertState.termAttribute);

View File

@ -303,7 +303,7 @@ public class TestCustomTermFreq extends LuceneTestCase {
new int[] {3, Integer.MAX_VALUE}),
fieldType);
doc2.add(field);
expectThrows(ArithmeticException.class, () -> {w.addDocument(doc2);});
expectThrows(IllegalArgumentException.class, () -> {w.addDocument(doc2);});
IndexReader r = DirectoryReader.open(w);
assertEquals(1, r.numDocs());