mirror of https://github.com/apache/lucene.git
fix clone() case that could incorrectly leave stored fields files open
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@757185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
04c0d1f81a
commit
c6f7aa41a3
|
@ -676,10 +676,7 @@ class SegmentReader extends DirectoryIndexReader {
|
|||
clone.freqStream = freqStream;
|
||||
clone.proxStream = proxStream;
|
||||
clone.termVectorsReaderOrig = termVectorsReaderOrig;
|
||||
|
||||
if (fieldsReaderOrig != null) {
|
||||
clone.fieldsReaderOrig = (FieldsReader) fieldsReaderOrig.clone();
|
||||
}
|
||||
clone.fieldsReaderOrig = fieldsReaderOrig;
|
||||
|
||||
if (doClone) {
|
||||
if (deletedDocs != null) {
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.lucene.index;
|
|||
import org.apache.lucene.index.SegmentReader.Norm;
|
||||
import org.apache.lucene.search.Similarity;
|
||||
import org.apache.lucene.analysis.SimpleAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.store.MockRAMDirectory;
|
||||
|
@ -440,4 +442,19 @@ public class TestIndexReaderClone extends LuceneTestCase {
|
|||
r1.close();
|
||||
dir1.close();
|
||||
}
|
||||
|
||||
public void testCloseStoredFields() throws Exception {
|
||||
final Directory dir = new MockRAMDirectory();
|
||||
IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
w.setUseCompoundFile(false);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("field", "yes it's stored", Field.Store.YES, Field.Index.ANALYZED));
|
||||
w.addDocument(doc);
|
||||
w.close();
|
||||
IndexReader r1 = IndexReader.open(dir);
|
||||
IndexReader r2 = (IndexReader) r1.clone(false);
|
||||
r1.close();
|
||||
r2.close();
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue