Apache Solr open-source search software
LUCENE-1010: fix corruption case, hit during merge, case when docs with and without term-vectors are mixed
Michael McCandless8315089cddad
diff --git a/CHANGES.txt b/CHANGES.txtindex 0459b79c9ef..97eb2678447 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -113,6 +113,12 @@ Bug fixes16. LUCENE-1006: Fixed QueryParser to accept a "" field value (zerolength quoted string.) (yonik)+17. LUCENE-1010: Fixed corruption case when document with no term+ vector fields is added after documents with term vector fields.+ This case is hit during merge and would cause an EOFException.+ This bug was introduced with LUCENE-984. (Andi Vajda via Mike+ McCandless)+New features1. LUCENE-906: Elision filter for French.diff --git a/src/java/org/apache/lucene/index/TermVectorsWriter.java b/src/java/org/apache/lucene/index/TermVectorsWriter.javaindex 9f9ebdb35db..046bac36485 100644--- a/src/java/org/apache/lucene/index/TermVectorsWriter.java+++ b/src/java/org/apache/lucene/index/TermVectorsWriter.java@@ -155,7 +155,8 @@ final class TermVectorsWriter {tvd.writeVLong(fieldPointer-lastFieldPointer);lastFieldPointer = fieldPointer;}- }+ } else+ tvd.writeVInt(0);}/** Close all streams. */diff --git a/src/test/org/apache/lucene/index/TestIndexWriter.java b/src/test/org/apache/lucene/index/TestIndexWriter.javaindex 5ab13ec4299..7ee20b4f4fb 100644--- a/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -1489,4 +1489,34 @@ public class TestIndexWriter extends TestCaseiw.close();dir.close();}++ // LUCENE-1010+ public void testNoTermVectorAfterTermVectorMerge() throws IOException {+ MockRAMDirectory dir = new MockRAMDirectory();+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true);+ Document document = new Document();+ document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.TOKENIZED,+ Field.TermVector.YES));+ iw.addDocument(document);+ iw.flush();++ document = new Document();+ document.add(new Field("tvtest", "x y z", Field.Store.NO, Field.Index.TOKENIZED,+ Field.TermVector.NO));+ iw.addDocument(document);+ // Make first segment+ iw.flush();++ iw.optimize();++ document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.TOKENIZED,+ Field.TermVector.YES));+ iw.addDocument(document);+ // Make 2nd segment+ iw.flush();+ iw.optimize();++ iw.close();+ dir.close();+ }}