mirror of https://github.com/apache/lucene.git
LUCENE-7854: restore the IllegalArgumentException if you index too many tokens in one field
This commit is contained in:
parent
bcce49c160
commit
6c3ece2b9f
|
@ -770,7 +770,11 @@ final class DefaultIndexingChain extends DocConsumer {
|
||||||
}
|
}
|
||||||
invertState.lastStartOffset = startOffset;
|
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);
|
//System.out.println(" term=" + invertState.termAttribute);
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class TestCustomTermFreq extends LuceneTestCase {
|
||||||
new int[] {3, Integer.MAX_VALUE}),
|
new int[] {3, Integer.MAX_VALUE}),
|
||||||
fieldType);
|
fieldType);
|
||||||
doc2.add(field);
|
doc2.add(field);
|
||||||
expectThrows(ArithmeticException.class, () -> {w.addDocument(doc2);});
|
expectThrows(IllegalArgumentException.class, () -> {w.addDocument(doc2);});
|
||||||
|
|
||||||
IndexReader r = DirectoryReader.open(w);
|
IndexReader r = DirectoryReader.open(w);
|
||||||
assertEquals(1, r.numDocs());
|
assertEquals(1, r.numDocs());
|
||||||
|
|
Loading…
Reference in New Issue