Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8610

NPE in TermsHashPerField.add() for TokenStreams with lazily instantiated token Attributes

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Resolved
    • Priority: Minor
    • Resolution: Not A Bug
    • Affects Version/s: 7.4, 8.0
    • Fix Version/s: None
    • Component/s: core/index
    • Labels:
      None

      Description

      DefaultIndexingChain.invert(...) callsĀ invertState.setAttributeSource(stream) before stream.incrementToken() is called.

      For instances of stream that lazily instantiate token attributes (e.g., as solr.PreAnalyzedField$PreAnalyzedTokenizer does upon the first call to incrementToken() that returns true), this can result in caching a null value in invertState.termAttribute for a given stream instance.

      Subsequent calls that reuse the same stream instance (reusing TokenStreamComponents) for field values with at least 1 token will call termHashPerField.start(...) which sets termsHashPerField.termAtt from the null value cached in the FieldInvertState.termAttribute. An NPE would be thrown when termsHashPerField.add() reasonably but incorrectly assumes a non-null value for termAtt.

        Attachments

        1. LUCENE-8610.patch
          19 kB
          Michael Gibney

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mgibney Michael Gibney
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: