lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Medinets" <medi...@mtolive.com>
Subject Bug when using IndexSearcher on empty RAMDirectory?
Date Mon, 28 Apr 2003 12:39:08 GMT
First I created a RAMDirectory and then searched it when it was empty. And I got a NullPointerException.
I looked in the API for a way to determine if the directory is empty so that I could add code
to prevent searching an empty directory, but I could not find such a method (like isEmpty?).

Does anyone have any suggestions or should I simply trap the NullPointerException?

Here is the example that causes the problem:

import java.io.IOException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.RAMDirectory;

public class BugTest {
    public static void main(String[] args) throws IOException {
        RAMDirectory indexStore = new RAMDirectory();
        IndexSearcher searcher = new IndexSearcher(indexStore);
    }
}

Here is the exception:

java.lang.NullPointerException
at org.apache.lucene.store.RAMInputStream.<init>(RAMDirectory.java:217)
at org.apache.lucene.store.RAMDirectory.openFile(RAMDirectory.java:182)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:71)
at org.apache.lucene.index.IndexReader$1.doBody(IndexReader.java:106)
at org.apache.lucene.store.Lock$With.run(Lock.java:116)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:103)
at org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:80)
at BugTest.main(BugTest.java:10)
Exception in thread "main" 

Thanks,
David Medinets
Quality = Resource Multiplication
http://www.codebits.com

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