You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2017/06/07 19:44:14 UTC

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

Repository: lucene-solr
Updated Branches:
  refs/heads/master bcce49c16 -> 6c3ece2b9


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6c3ece2b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6c3ece2b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6c3ece2b

Branch: refs/heads/master
Commit: 6c3ece2b9f97926769849b4008ed7f10276f0b14
Parents: bcce49c
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Jun 7 15:43:56 2017 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Jun 7 15:43:56 2017 -0400

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/index/DefaultIndexingChain.java | 6 +++++-
 .../src/test/org/apache/lucene/index/TestCustomTermFreq.java   | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6c3ece2b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
index df739d8..f2c3de1 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
@@ -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);
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6c3ece2b/lucene/core/src/test/org/apache/lucene/index/TestCustomTermFreq.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCustomTermFreq.java b/lucene/core/src/test/org/apache/lucene/index/TestCustomTermFreq.java
index 5b38f57..d2eff25 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestCustomTermFreq.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestCustomTermFreq.java
@@ -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());