Index: . =================================================================== --- . (revision 1563739) +++ . (working copy) Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /lucene/dev/trunk:r1562657 Index: lucene =================================================================== --- lucene (revision 1563739) +++ lucene (working copy) Property changes on: lucene ___________________________________________________________________ Modified: svn:mergeinfo Merged /lucene/dev/trunk/lucene:r1562657 Index: lucene/core =================================================================== --- lucene/core (revision 1563739) +++ lucene/core (working copy) Property changes on: lucene/core ___________________________________________________________________ Modified: svn:mergeinfo Merged /lucene/dev/trunk/lucene/core:r1562657 Index: lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java =================================================================== --- lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java (working copy) +++ lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java (working copy) @@ -18,7 +18,6 @@ */ import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.Tokenizer; @@ -33,6 +32,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.io.Reader; /** * Test adding to the info stream when there's an exception thrown during field analysis. @@ -48,8 +48,8 @@ private static class ThrowingAnalyzer extends Analyzer { @Override - protected TokenStreamComponents createComponents(String fieldName) { - Tokenizer tokenizer = new MockTokenizer(); + protected TokenStreamComponents createComponents(String fieldName, Reader input) { + Tokenizer tokenizer = new MockTokenizer(input); if (fieldName.equals("distinctiveFieldName")) { TokenFilter tosser = new TokenFilter(tokenizer) { @Override Index: lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java (revision 1563739) +++ lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java (working copy) @@ -92,6 +92,14 @@ fieldState.position += analyzed ? docState.analyzer.getPositionIncrementGap(fieldInfo.name) : 0; } + /* + * To assist people in tracking down problems in analysis components, we wish to write the field name to the infostream + * when we fail. We expect some caller to eventually deal with the real exception, so we don't want any 'catch' clauses, + * but rather a finally that takes note of the problem. + */ + + boolean succeededInProcessingField = false; + final TokenStream stream = field.tokenStream(docState.analyzer); // reset the TokenStream to the first token stream.reset(); @@ -164,6 +172,7 @@ // new segment: consumer.add(); success = true; + } finally { if (!success) { docState.docWriter.setAborting(); @@ -171,6 +180,7 @@ } fieldState.length++; fieldState.position++; + } while (stream.incrementToken()); } // trigger streams to perform end-of-stream operations @@ -180,7 +190,12 @@ fieldState.position += posIncrAttribute.getPositionIncrement(); fieldState.offset += offsetAttribute.endOffset(); success2 = true; + /* if success was false above there is an exception coming through and we won't get here.*/ + succeededInProcessingField = true; } finally { + if (!succeededInProcessingField && docState.infoStream.isEnabled("DW")) { + docState.infoStream.message("DW", "An exception was thrown while processing field " + fieldInfo.name); + } if (!success2) { IOUtils.closeWhileHandlingException(stream); } else {