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 petite_abeille <pe...@mac.com> on 2003/10/21 18:56:29 UTC

Weird NPE in RAMInputStream when merging indices

Hello,

What could cause such weird exception?

RAMInputStream.<init>: java.lang.NullPointerException
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.FieldInfos.<init>(FieldInfos.java:78)
at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:116)
at 
org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:378)
at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:298)
at org.apache.lucene.index.IndexWriter.addIndexes(IndexWriter.java:313)

I don't know if this is a one off as I cannot reproduce this problem 
nor I have seen this before, but I thought I could as well ask.

This is triggered by merging a RAMDirectory into a FSDirectory. Looking 
at the RAMDirectory source code, this exception seems to indicate that 
the file argument to the RAMInputStream constructor is null... how 
could that ever happen?

Here is the code which triggers this weirdness:

     this.writer().addIndexes( new Directory[] { aRamDirectory } );

The RAM writer is checked before invoking this code to make sure there 
is some content in the RAM directory:

     aRamWriter.docCount() > 0

This has been working very reliably since the dawn of time, so I'm a 
little bit at loss as how to diagnose this weird exception...

Any ideas?

Thanks.

Cheers,

PA.


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


Re: Weird NPE in RAMInputStream when merging indices

Posted by Otis Gospodnetic <ot...@yahoo.com>.
That's why I emphasized that Hashtable doesn't allow nulls.
If this is happening often, then yes, that is the thing to be
suspicious about, and is easily to test by modifying your local copy of
RAMDirectory.

Otis

--- petite_abeille <pe...@mac.com> wrote:
> Hi Otis,
> 
> On Wednesday, Oct 22, 2003, at 18:06 Europe/Amsterdam, Otis
> Gospodnetic 
> wrote:
> 
> > Since 'files' is a Hashtable, neither the key nor the value (file)
> can
> > be null, even though the NPE in RAMInputStream constructor implies
> that
> > file was null.
> 
> Yep... pretty weird... but looking at openFile(String name)... could
> it 
> somehow be possible that the name is invalid for some reasons and 
> therefore doesn't exists in the Hashtable? So files.get(name) would 
> return null and new RAMInputStream(file) would then raise a NPE?
> 
> This would not explain why the name is invalid in the first place... 
> but that could be a start for an investigation... what do you think?
> 
> Cheers,
> 
> PA.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Re: Weird NPE in RAMInputStream when merging indices

Posted by petite_abeille <pe...@mac.com>.
Hi Otis,

On Wednesday, Oct 22, 2003, at 18:06 Europe/Amsterdam, Otis Gospodnetic 
wrote:

> Since 'files' is a Hashtable, neither the key nor the value (file) can
> be null, even though the NPE in RAMInputStream constructor implies that
> file was null.

Yep... pretty weird... but looking at openFile(String name)... could it 
somehow be possible that the name is invalid for some reasons and 
therefore doesn't exists in the Hashtable? So files.get(name) would 
return null and new RAMInputStream(file) would then raise a NPE?

This would not explain why the name is invalid in the first place... 
but that could be a start for an investigation... what do you think?

Cheers,

PA.


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


Re: Weird NPE in RAMInputStream when merging indices

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Hm, beat me.
The code in question seems to be:

  public RAMInputStream(RAMFile f) {
    file = f;
    length = file.length;
  }

...which is called from:

  /** Returns a stream reading an existing file. */
  public final InputStream openFile(String name) {
    RAMFile file = (RAMFile)files.get(name);
    return new RAMInputStream(file);
  }

Since 'files' is a Hashtable, neither the key nor the value (file) can
be null, even though the NPE in RAMInputStream constructor implies that
file was null.

Otis


--- petite_abeille <pe...@mac.com> wrote:
> Hello,
> 
> What could cause such weird exception?
> 
> RAMInputStream.<init>: java.lang.NullPointerException
> 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.FieldInfos.<init>(FieldInfos.java:78)
> at
> org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:116)
> at 
>
org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:378)
> at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:298)
> at
> org.apache.lucene.index.IndexWriter.addIndexes(IndexWriter.java:313)
> 
> I don't know if this is a one off as I cannot reproduce this problem 
> nor I have seen this before, but I thought I could as well ask.
> 
> This is triggered by merging a RAMDirectory into a FSDirectory.
> Looking 
> at the RAMDirectory source code, this exception seems to indicate
> that 
> the file argument to the RAMInputStream constructor is null... how 
> could that ever happen?
> 
> Here is the code which triggers this weirdness:
> 
>      this.writer().addIndexes( new Directory[] { aRamDirectory } );
> 
> The RAM writer is checked before invoking this code to make sure
> there 
> is some content in the RAM directory:
> 
>      aRamWriter.docCount() > 0
> 
> This has been working very reliably since the dawn of time, so I'm a 
> little bit at loss as how to diagnose this weird exception...
> 
> Any ideas?
> 
> Thanks.
> 
> Cheers,
> 
> PA.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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