You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by David Medinets <me...@mtolive.com> on 2003/04/28 14:39:08 UTC
Bug when using IndexSearcher on empty RAMDirectory?
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
Re: Bug when using IndexSearcher on empty RAMDirectory?
Posted by David Medinets <me...@mtolive.com>.
Most excellent. Thanks.
----- Original Message -----
From: "petite_abeille" <pe...@mac.com>
> > Does anyone have any suggestions or should I simply trap the
> > NullPointerException?
>
> http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/
> IndexReader.html#indexExists(org.apache.lucene.store.Directory)?
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Bug when using IndexSearcher on empty RAMDirectory?
Posted by petite_abeille <pe...@mac.com>.
On Monday, Apr 28, 2003, at 14:39 Europe/Zurich, David Medinets wrote:
> Does anyone have any suggestions or should I simply trap the
> NullPointerException?
http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/
IndexReader.html#indexExists(org.apache.lucene.store.Directory)?
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org