lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernhard Messer (JIRA)" <>
Subject [jira] Created: (LUCENE-758) IndexReader.isCurrent fails when using two IndexReaders
Date Fri, 22 Dec 2006 12:42:21 GMT
IndexReader.isCurrent fails when using two IndexReaders

                 Key: LUCENE-758
             Project: Lucene - Java
          Issue Type: Bug
    Affects Versions: 2.0.1
         Environment: Operating System: other
Platform: other
            Reporter: Bernhard Messer
            Priority: Minor

there is a problem in IndexReader.isCurrent() if using two reader instances where one of them
is based on a RAMDirectory. If there is an index and we open two IndexReaders where one is
based on a FSDirectory and the other is based on a RAMDirectory, the IndexReader using the
RAMDirectory does not recognize when the underlaying index has changed. The method IndexReader.isCurrent()
always returns true. The testcase below shows the problem.

I did not find an ideal solution to solve the problem. I think the best way would be to change
the IndexReader.isCurrent() implementation from:
  public boolean isCurrent() throws IOException {
    return SegmentInfos.readCurrentVersion(directory) == segmentInfos.getVersion();
to something like:
  public boolean isCurrent() throws IOException {
    return directory.readCurrentVersion() == segmentInfos.getVersion();
As far as i can see this would work for FS- and RAMDirectory. But then the implementing Directory
classes have to know about "segment" files and there formating details.
What do others think ?

   * additional testcase for IndexReaderTest to show the problem when using two different
  public void testIsCurrentWithCombined() throws Exception {
      String tempDir = System.getProperty("tempDir");
      if (tempDir == null)
          throw new IOException("tempDir undefined, cannot run test");

      File indexDir = new File(tempDir, "lucenetestiscurrent");
      Directory fsStore = FSDirectory.getDirectory(indexDir, true);
      IndexWriter writer = new IndexWriter(fsStore, new SimpleAnalyzer(), true);
      IndexReader reader1 =;
      IndexReader reader2 = RAMDirectory(fsStore));
      // BUG: reader based on the RAMDirectory does not recognize the index change.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message