You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by Chris Mattmann <ch...@jpl.nasa.gov> on 2006/03/14 00:25:42 UTC

Null Pointer exception in AnalyzerFactory?

Hi Folks,

  I updated to the latest SVN revision (385691) today, and I am now seeing a
Null Pointer exception in the AnalyzerFactory.java class. It seems that in
some cases, the method:

  private Extension getExtension(String lang) {     Extension extension =
(Extension) this.conf.getObject(lang);    if (extension == null) {
extension = findExtension(lang);      if (extension != null) {
this.conf.setObject(lang, extension);      }    }    return extension;  }


Has a null "lang" parameter passed to it, which causes a NullPointer
exception at line: 81 in
src/java/org/apache/nutch/analyzer/AnalyzerFactory.java

I found that if I checked for null in the lang variable, and returned null
if lang == null, that my crawl finished. Here is a small patch that will fix
the crawl:

Index: 
/Users/mattmann/src/nutch/src/java/org/apache/nutch/analysis/AnalyzerFactory
.java ===================================================================
--- 
/Users/mattmann/src/nutch/src/java/org/apache/nutch/analysis/AnalyzerFactory
.java    (revision 385691) +++
/Users/mattmann/src/nutch/src/java/org/apache/nutch/analysis/AnalyzerFactory
.java    (working copy) @@ -78,14 +78,19 @@    private Extension
getExtension(String lang) { -    Extension extension = (Extension)
this.conf.getObject(lang); -    if (extension == null) { -      extension =
findExtension(lang); -      if (extension != null) { -
this.conf.setObject(lang, extension); -      } -    } -    return extension;
+    if(lang == null){ +        return null; +    } +    else{ +
Extension extension = (Extension) this.conf.getObject(lang); +        if
(extension == null) { +          extension = findExtension(lang); +
if (extension != null) { +            this.conf.setObject(lang, extension);
+          } +        } +        return extension;        +    }   }
private Extension findExtension(String lang) {


NOTE: not sure if returning null is the right thing to do here, but hey, at
least it made my crawl finish! :-)

Cheers,
  Chris



______________________________________________
Chris A. Mattmann
Chris.Mattmann@jpl.nasa.gov
Staff Member
Modeling and Data Management Systems Section (387)
Data Management Systems and Technologies Group

_________________________________________________
Jet Propulsion Laboratory            Pasadena, CA
Office: 171-266B                        Mailstop:  171-246

_______________________________________________________

Disclaimer:  The opinions presented within are my own and do not reflect
those of either NASA, JPL, or the California Institute of Technology.


Re: Null Pointer exception in AnalyzerFactory?

Posted by Chris Mattmann <ch...@jpl.nasa.gov>.
Thanks Jerome! :-)

Cheers,
  Chris



On 3/13/06 4:02 PM, "Jérôme Charron" <je...@gmail.com> wrote:

>>   I updated to the latest SVN revision (385691) today, and I am now seeing
>> a
>> Null Pointer exception in the AnalyzerFactory.java class.
> 
> Fixed (r385702). Thanks Chris.
> 
> 
>> NOTE: not sure if returning null is the right thing to do here, but hey,
>> at
>> least it made my crawl finish! :-)
> 
> It is the right thing to do.
> 
> Cheers,
> 
> Jérôme
> 
> --
> http://motrech.free.fr/
> http://www.frutch.org/

______________________________________________
Chris A. Mattmann
Chris.Mattmann@jpl.nasa.gov
Staff Member
Modeling and Data Management Systems Section (387)
Data Management Systems and Technologies Group

_________________________________________________
Jet Propulsion Laboratory            Pasadena, CA
Office: 171-266B                        Mailstop:  171-246
_______________________________________________________

Disclaimer:  The opinions presented within are my own and do not reflect
those of either NASA, JPL, or the California Institute of Technology.



Re: Null Pointer exception in AnalyzerFactory?

Posted by Jérôme Charron <je...@gmail.com>.
>   I updated to the latest SVN revision (385691) today, and I am now seeing
> a
> Null Pointer exception in the AnalyzerFactory.java class.

Fixed (r385702). Thanks Chris.


> NOTE: not sure if returning null is the right thing to do here, but hey,
> at
> least it made my crawl finish! :-)

It is the right thing to do.

Cheers,

Jérôme

--
http://motrech.free.fr/
http://www.frutch.org/