Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-4366

NPE sometimes in SpellCheckComponent when dictionary name not defined

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0
    • None
    • spellchecker
    • None

    Description

      SpellCheckComponent sometimes detects and reports dictionary names that are not defined, but not always. I stumbled on two cases where an NPE occurs rather than a 404 status code return.

      Repro:

      Add this snippet to the Solr 4.0 example solrconfig.xml:

        <requestHandler name="/spellBug" class="solr.SearchHandler" startup="lazy">
          <lst name="defaults">
            <str name="df">name</str>
            <str name="spellcheck">on</str>
            <str name="spellcheck.dictionary">other-name</str>
          </lst>
          <arr name="last-components">
            <str>spellcheckBug</str>
          </arr>
        </requestHandler>
      
        <searchComponent name="spellcheckBug" class="solr.SpellCheckComponent">
          <lst name="spellchecker">
            <str name="name">some-name</str>
            <str name="classname">solr.FileBasedSpellChecker</str>
            <str name="sourceLocation">SpellDict.txt</str>
            <str name="buildOnCommit">true</str>
          </lst>
        </searchComponent>
      

      Case 1: spellcheck.build=true parameter specified

      Execute this request:

      curl "http://localhost:8983/solr/spellBug/?q=test&spellcheck.build=true"
      

      Produces this NPE:

      SEVERE: null:java.lang.NullPointerException
              at org.apache.solr.handler.component.SpellCheckComponent.prepare(SpellCheckComponent.java:108)
              at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:185)
      

      Case 1a: Ditto for spellcheck.reload parameter specified

      curl "http://localhost:8983/solr/spellBug/?q=test&spellcheck.reload=true"
      

      Case 2: spellcheck.q parameter specified

      Execute this request:

      curl "http://localhost:8983/solr/spellBug/?spellcheck.q=test"
      

      Produces this NPE:

      SEVERE: null:java.lang.NullPointerException
              at org.apache.solr.handler.component.SpellCheckComponent.process(SpellCheckComponent.java:130)
              at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:206)
      

      The first case fails in the "prepare" method of SpellCheckComponent, while the second case fails in the "process" method. Both methods call getSpellChecker, but then proceed to reference the return value without checking if it is null.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkrupan Jack Krupansky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: