Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 47400 invoked from network); 12 Sep 2002 16:23:42 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Sep 2002 16:23:42 -0000 Received: (qmail 3875 invoked by uid 97); 12 Sep 2002 16:23:55 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org Received: (qmail 3729 invoked by uid 97); 12 Sep 2002 16:23:54 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 3559 invoked by uid 98); 12 Sep 2002 16:23:52 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <20020912162315.38278.qmail@web12704.mail.yahoo.com> Date: Thu, 12 Sep 2002 09:23:15 -0700 (PDT) From: Otis Gospodnetic Subject: Re: Nullpointer in code To: Lucene Developers List Cc: rasik.pandey@ajlsm.com In-Reply-To: <000001c25a71$770f4950$697ba8c0@DIDEROT> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 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: > > For additional commands, e-mail: > > __________________________________________________ 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: For additional commands, e-mail: