lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r757185 - in /lucene/java/trunk/src: java/org/apache/lucene/index/SegmentReader.java test/org/apache/lucene/index/TestIndexReaderClone.java
Date Sun, 22 Mar 2009 13:21:58 GMT
Author: mikemccand
Date: Sun Mar 22 13:21:58 2009
New Revision: 757185

URL: http://svn.apache.org/viewvc?rev=757185&view=rev
Log:
fix clone() case that could incorrectly leave stored fields files open

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=757185&r1=757184&r2=757185&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Sun Mar 22 13:21:58
2009
@@ -676,10 +676,7 @@
       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) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java?rev=757185&r1=757184&r2=757185&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java Sun Mar 22
13:21:58 2009
@@ -20,6 +20,8 @@
 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 @@
     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();
+  }
 }



Mime
View raw message