Hmm... the code looks OK.
Though: can multiple threads call that method at the same time?
And: could in-flight searches be using the reader, when you close it?
If instead of opening with String indexPath, you pass in an
FSDirectory that you opened, do you still hit the
AlreadyClosedException?
Can you post the full exception?
Mike
Chris Salem wrote:
I'm using Lucene 2.4.1 and I'm still getting an
AlreadyClosedException when trying to reopen an IndexReader. Here's
the code I'm using, in case I'm doing something wrong, there isn't
an error if I don't close the old reader:
String indexPath = "C:\\Lucene\\test";
IndexReader reader = IndexReader.open(indexPath);
..
IndexReader tempReader;
try {
tempReader = reader.reopen();
if(tempReader != reader){
System.out.println("reader reopened");
reader.close();
}else{
System.out.println("reader has not changed");
}
reader = tempReader;
return this;
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Sincerely,
Chris Salem
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org