Lucene - Core
  1. Lucene - Core
  2. LUCENE-6385

NullPointerException from Highlighter.getBestFragment()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 5.2, 6.0
    • Component/s: modules/highlighter
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      When testing against the 5.1 nightly snapshots I've come across a NullPointerException in highlighting when nothing would be highlighted. This does not happen with 5.0.

      java.lang.NullPointerException
      	at __randomizedtesting.SeedInfo.seed([3EDC6EB0FA552B34:9971866E394F5FD0]:0)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extractWeightedSpanTerms(WeightedSpanTermExtractor.java:311)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract(WeightedSpanTermExtractor.java:151)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.getWeightedSpanTerms(WeightedSpanTermExtractor.java:515)
      	at org.apache.lucene.search.highlight.QueryScorer.initExtractor(QueryScorer.java:219)
      	at org.apache.lucene.search.highlight.QueryScorer.init(QueryScorer.java:187)
      	at org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:196)
      	at org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:156)
      	at org.apache.lucene.search.highlight.Highlighter.getBestFragment(Highlighter.java:102)
      	at org.apache.lucene.search.highlight.Highlighter.getBestFragment(Highlighter.java:80)
      	at org.apache.lucene.search.highlight.MissesTest.testPhraseQuery(MissesTest.java:50)
      

      I've written a small unit test and used git bisect to narrow the regression to the following commit:

      commit 24e4eefaefb1837d1d4fa35f7669c2b264f872ac
      Author: Michael McCandless <mikemccand@apache.org>
      Date:   Tue Mar 31 08:48:28 2015 +0000
      
          LUCENE-6308: cutover Spans to DISI, reuse ConjunctionDISI, use two-phased iteration
          
          git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1670273 13f79535-47bb-0310-9956-ffa450edef68
      

      The problem looks quite simple, WeightedSpanTermExtractor.extractWeightedSpanTerms() needs an early return if SpanQuery.getSpans() returns null. All other callers check against this.

      Unit test and fix (against the regressed commit) attached.

        Activity

        Hide
        Ramkumar Aiyengar added a comment -

        Michael McCandless, Timothy Potter: Looks like this is a blocker for 5.1

        Show
        Ramkumar Aiyengar added a comment - Michael McCandless , Timothy Potter : Looks like this is a blocker for 5.1
        Hide
        Robert Muir added a comment -

        The fix looks fine. I probably messed this up on LUCENE-6308.

        Show
        Robert Muir added a comment - The fix looks fine. I probably messed this up on LUCENE-6308 .
        Hide
        Robert Muir added a comment -

        I'm just running checks/tests and plan to commit this later tonight. Thanks for the fix and nice test Terry.

        Show
        Robert Muir added a comment - I'm just running checks/tests and plan to commit this later tonight. Thanks for the fix and nice test Terry.
        Hide
        Robert Muir added a comment -

        The issue does not impact 5.1. LUCENE-6308 was only committed to 5.2 (http://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x/).

        Show
        Robert Muir added a comment - The issue does not impact 5.1. LUCENE-6308 was only committed to 5.2 ( http://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x/ ).
        Hide
        ASF subversion and git services added a comment -

        Commit 1671064 from Robert Muir in branch 'dev/trunk'
        [ https://svn.apache.org/r1671064 ]

        LUCENE-6385: add null check to WeightedSpanTermExtractor

        Show
        ASF subversion and git services added a comment - Commit 1671064 from Robert Muir in branch 'dev/trunk' [ https://svn.apache.org/r1671064 ] LUCENE-6385 : add null check to WeightedSpanTermExtractor
        Hide
        ASF subversion and git services added a comment -

        Commit 1671065 from Robert Muir in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1671065 ]

        LUCENE-6385: add null check to WeightedSpanTermExtractor

        Show
        ASF subversion and git services added a comment - Commit 1671065 from Robert Muir in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1671065 ] LUCENE-6385 : add null check to WeightedSpanTermExtractor
        Hide
        Robert Muir added a comment -

        Thanks again Terry

        Show
        Robert Muir added a comment - Thanks again Terry
        Hide
        Anshum Gupta added a comment -

        Bulk close for 5.2.0.

        Show
        Anshum Gupta added a comment - Bulk close for 5.2.0.

          People

          • Assignee:
            Robert Muir
            Reporter:
            Terry Smith
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development