lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olga Dadasheva" <olga_dadash...@harvard.edu>
Subject "Already closed" IOException during index backup
Date Fri, 02 Apr 2004 03:09:34 GMT
Hi,

I am using Lucene latest CVS build and getting "Already closed" IOException during index backup.

This code used to work , and I can still make it work if I set writer.setUseCompoundFile(false);


Below is the stak trace and test code.


java.io.IOException: Already closed
Exception during index backup. java.io.IOException: Already closed
 at org.apache.lucene.index.CompoundFileReader.close(CompoundFileReader.java:110)
 at org.apache.lucene.index.SegmentReader.doClose(SegmentReader.java:170)
 at org.apache.lucene.index.IndexReader.close(IndexReader.java:413)
 at lucene.TestBackupIndex.backupCurrentIndex(TestBackupIndex.java:52)
 at lucene.TestBackupIndex.main(TestBackupIndex.java:43)


public class TestBackupIndex {
 String indexPath = "index";
 public TestBackupIndex() {
     try {
       IndexWriter writer = new IndexWriter(indexPath, new StandardAnalyzer(), true);
       Document doc = new Document();
       doc.add(new Field("category", "public", true, true, false));
       doc.add(new Field("content", "quick brown fox", true, true, false));
       writer.addDocument(doc);
       writer.optimize();
       writer.close();
       System.out.println("index built");

     } catch (IOException e) {
      e.printStackTrace();
     }
 }
 public static void main(String[] args) {
  TestBackupIndex test = new TestBackupIndex();
  test.backupCurrentIndex("backup");
 }
 
 public void backupCurrentIndex(String backupDir){
  try {
   IndexReader reader = IndexReader.open(indexPath);
   IndexWriter writer = new IndexWriter(backupDir, new StandardAnalyzer(), true);
   writer.addIndexes(new IndexReader[] { reader });
   writer.close();
   reader.close();
  } catch (IOException e) {
   System.out.println("Exception during index backup. "+e);
   e.printStackTrace();
  }
 }
 
}


Thank you,
-Olga

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message