You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Rasik Pandey <ra...@ajlsm.com> on 2002/09/19 13:20:02 UTC

RE : RE : RE : Nullpointer in code

Yes the change was finally in WildCardTermEnum. My apologies for the
less than concise original mail.......

-----Message d'origine-----
De : Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com] 
Envoyé : jeudi 19 septembre 2002 08:09
À : Lucene Developers List
Objet : Re: RE : RE : Nullpointer in code


Ah, that explains the large diff.
The diff is for WildCardTermEnum?

Maybe Doug can comment before we start with defensive programming...

Otis


--- Rasik Pandey <ra...@ajlsm.com> wrote:
> The only significant change in the diff which I sent was this:
> 
> 95c98
> <       if (field == term.field()) {
> ---
> >       if (term != null && field == term.field()) {
> 104c107
> 
> 
> The other changes were just from my IDE reformatting the code.
> 
> -----Message d'origine-----
> De : Rasik Pandey [mailto:rasik.pandey@ajlsm.com]
> Envoyé : jeudi 12 septembre 2002 19:06
> À : 'Lucene Developers List'
> Objet : RE : Nullpointer in code
> 
> 
> Otis,
> Here a the test program that will generate the null pointer and the 
> requested diff. Hope they are helpful.
> 
> Thanks,
> Rasik Pandey
> 
> 
> 
> -----Message d'origine-----
> De : Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> Envoyé : jeudi 12 septembre 2002 18:23
> À : Lucene Developers List
> Cc : rasik.pandey@ajlsm.com
> Objet : Re: Nullpointer in code
> 
> 
> Rasik,
> 
> Thanks for feedback, but that stuff is a bit hard to read. The best 
> way to help would be to write a class that demonstrates this,
> then fix your code to work, then make a diff between your fixed code
> and
> the code in the CVS, and finally, it would be great to have a unit
> test
> for it, but I can write that later.
> 
> Thanks,
> Otis
> 
> 
> --- Rasik Pandey <ra...@ajlsm.com> wrote:
> > Developers,
> > I am encountering a null pointer exception when executing a wild
> card
> > query search on an empty index which doesn't contain any terms  and
> of
> > course not the Term generated from the wild card query (ie the 
> > WildCardTermEnum has an empty "actualEnum"). Please see below for 
> > what i propose to be the fix (simple). I assume that this is 
> > sufficient or would a change in one of the SegmentReader or 
> > TermsInfosReader classes
> > be more appropriate (not likely)?
> > 
> > I do not have access to commit this change, so if you deem that it
> is
> > necessary can you please make the modification.
> > 
> > Cheers,
> > Rasik Pandey
> > 
> > Basically in the constructor of WildCardTermEnum the constructor 
> > calls;
> > 
> >       setEnum(reader.terms(new Term(searchTerm.field(), pre)));
> > 		----or
> > 		super.setEnum(an empty termEnum); or
> FilteredTermEnum.setEnum(an
> > empty termEnum);
> > 
> > 
> > Then in FilteredTermnEnum:
> > protected void setEnum(TermEnum actualEnum) throws IOException {
> >         this.actualEnum = actualEnum;
> >         // Find the first term that matches
> >         
> > 
> > 	!!!!!!!!the result of actualEnum.term(); is null in my
> case!!!!!!!!!
> > 	Term term = actualEnum.term();
> >  
> >
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> >   
> > 
> > 		!!!!!!!!!!!!the below line leads to the null
> pointer!!!!!!!!!!
> > 		if (termCompare(term)) 
> > 		!!!!!!!!!!!!!!!!!!!!see
> below!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > 
> >             currentTerm = term;
> >         else next();
> >     }
> > 
> > 
> > Then back in WildCardTermEnum:
> > 
> > final protected boolean termCompare(Term term) {
> >       !!!!!!!!!!!the below line should test to ensure that "term"
> is
> > not null!!!!!!
> > 	if (field == term.field()) {
> > 	!!!!!!!!!!!!!!!!see below line for the simple 
> > fix!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> >       
> > 	!!!!!!!!!!!!!!!!!below is the changed line for the simple 
> > fix!!!!!!!!!!!!!!!!!!!!!!!!
> > 	if (term != null && field == term.field()) {
> > 	
> >
>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > !!!!!!!!!!!!!
> >           String searchText = term.text();
> >           if (searchText.startsWith(pre)) {
> >             return wildcardEquals(text, 0, searchText, preLen);
> >           }
> >       }
> >       endEnum = true;
> >       return false;
> >   }
> > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Yahoo! - We Remember
> 9-11: A tribute to the more than 3,000 lives lost 
> http://dir.remember.yahoo.com/tribute
> 
> --
> To unsubscribe, e-mail: 
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>