LUCENE-5710: don't swallow innner immense term exception

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1598275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-05-29 12:28:25 +00:00
parent f99a9d7ab0
commit 753e0a2592
3 changed files with 8 additions and 2 deletions

View File

@ -231,6 +231,10 @@ Bug fixes
* LUCENE-5704: Fix compilation error with Java 8u20. (Uwe Schindler)
* LUCENE-5710: Include the inner exception as the cause and in the
exception message when an immense term is hit during indexing (Lee
Hinman via Mike McCandless)
Test Framework
* LUCENE-5622: Fail tests if they print over the given limit of bytes to

View File

@ -648,12 +648,12 @@ final class DefaultIndexingChain extends DocConsumer {
byte[] prefix = new byte[30];
BytesRef bigTerm = invertState.termAttribute.getBytesRef();
System.arraycopy(bigTerm.bytes, bigTerm.offset, prefix, 0, 30);
String msg = "Document contains at least one immense term in field=\"" + fieldInfo.name + "\" (whose UTF8 encoding is longer than the max length " + DocumentsWriterPerThread.MAX_TERM_LENGTH_UTF8 + "), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '" + Arrays.toString(prefix) + "...'";
String msg = "Document contains at least one immense term in field=\"" + fieldInfo.name + "\" (whose UTF8 encoding is longer than the max length " + DocumentsWriterPerThread.MAX_TERM_LENGTH_UTF8 + "), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '" + Arrays.toString(prefix) + "...', original message: " + e.getMessage();
if (docState.infoStream.isEnabled("IW")) {
docState.infoStream.message("IW", "ERROR: " + msg);
}
// Document will be deleted above:
throw new IllegalArgumentException(msg);
throw new IllegalArgumentException(msg, e);
} finally {
if (succeededInProcessingField == false && aborting) {
docState.docWriter.setAborting();

View File

@ -97,6 +97,8 @@ public class TestExceedMaxTermLength extends LuceneTestCase {
msg.contains(maxLengthMsg));
assertTrue("IllegalArgumentException didn't mention field name ("+name+"): " + msg,
msg.contains(name));
assertTrue("IllegalArgumentException didn't mention original message: " + msg,
msg.contains("bytes can be at most") && msg.contains("in length; got"));
}
} finally {
w.shutdown();