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 jm <jm...@gmail.com> on 2007/02/26 17:10:58 UTC

NPE in RAMDirectory after upgrade to 2.1

Hello all,

I have two processes running in parallel, each one adding and deleting
to its own set of indexes. Since I upgraded to 2.1 I am getting a NPE
at RAMDirectory.java line 207 in one of the processes.

Line 207 is:
      RAMFile existing = (RAMFile)fileMap.get(name);
the stack trace is:
java.lang.NullPointerException
org.apache.lucene.store.RAMDirectory.createOutput(RAMDirectory.java:207)
org.apache.lucene.index.FieldInfos.write(FieldInfos.java:256)
org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:75)
org.apache.lucene.index.IndexWriter.buildSingleDocSegment(IndexWriter.java:706)
org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:694)
org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:680)


I understand this RAMDirectory is something used internally by the
FSDirectories.

I have been double checking my code and I cannot see anything wrong.
Besided upgrading to lucene 2.1 I made some changes to take advantage
of new features (mainly set the locking factory of my indexes to be
the native one, IndexWriter deletes stuff).

someone has a clue? I tried to reproduce in my workstation but had no
success, but it happens consistently in my prod environment.

thanks
javi

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: NPE in RAMDirectory after upgrade to 2.1

Posted by Michael McCandless <lu...@mikemccandless.com>.
"jm" <jm...@gmail.com> wrote:
> You were right. As I have many indexes I keep a cache of the
> IndexWriters, and in some specific case (that cannot happen in my dev
> env) I was closing them without removing them from the cache. Somehow
> it was working before 2.1, and upgrading made the error clear.

OK, glad you got to the bottom of it!

But, I don't think this error (NPE) is particularly clear (though it
is better than pre-2.1 which, I think, would in fact let the writer
run without holding the write lock).  I will open a Jira issue for
this.  I think we should explicitly detect when the IndexWriter is
used after being closed.

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: NPE in RAMDirectory after upgrade to 2.1

Posted by jm <jm...@gmail.com>.
Mike,

You were right. As I have many indexes I keep a cache of the
IndexWriters, and in some specific case (that cannot happen in my dev
env) I was closing them without removing them from the cache. Somehow
it was working before 2.1, and upgrading made the error clear.

thanks
javi

On 2/26/07, Michael McCandless <lu...@mikemccandless.com> wrote:
>
> "jm" <jm...@gmail.com> wrote:
>
> > I have two processes running in parallel, each one adding and deleting
> > to its own set of indexes. Since I upgraded to 2.1 I am getting a NPE
> > at RAMDirectory.java line 207 in one of the processes.
> >
> > Line 207 is:
> >       RAMFile existing = (RAMFile)fileMap.get(name);
> > the stack trace is:
> > java.lang.NullPointerException
> > org.apache.lucene.store.RAMDirectory.createOutput(RAMDirectory.java:207)
> > org.apache.lucene.index.FieldInfos.write(FieldInfos.java:256)
> > org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:75)
> > org.apache.lucene.index.IndexWriter.buildSingleDocSegment(IndexWriter.java:706)
> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:694)
> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:680)
>
> Hmm.  One thing that changed in 2.1 is when a RAMDirectory is closed
> it now sets fileMap to null (which it did not pre-2.1).
>
> Is it possible you are accidentally closing a writer but then calling
> its addDocument method?
>
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: NPE in RAMDirectory after upgrade to 2.1

Posted by Michael McCandless <lu...@mikemccandless.com>.
"jm" <jm...@gmail.com> wrote:

> I have two processes running in parallel, each one adding and deleting
> to its own set of indexes. Since I upgraded to 2.1 I am getting a NPE
> at RAMDirectory.java line 207 in one of the processes.
> 
> Line 207 is:
>       RAMFile existing = (RAMFile)fileMap.get(name);
> the stack trace is:
> java.lang.NullPointerException
> org.apache.lucene.store.RAMDirectory.createOutput(RAMDirectory.java:207)
> org.apache.lucene.index.FieldInfos.write(FieldInfos.java:256)
> org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:75)
> org.apache.lucene.index.IndexWriter.buildSingleDocSegment(IndexWriter.java:706)
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:694)
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:680)

Hmm.  One thing that changed in 2.1 is when a RAMDirectory is closed
it now sets fileMap to null (which it did not pre-2.1).

Is it possible you are accidentally closing a writer but then calling
its addDocument method?

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org