Lucene - Core
  1. Lucene - Core
  2. LUCENE-1404

NPE in NearSpansUnordered.isPayloadAvailable()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4, 2.9
    • Component/s: core/query/scoring
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Using RC1 of lucene 2.4 resulted in null pointer exception with some constructed SpanNearQueries

      Implementation of isPayloadAvailable() (results in exception)

       public boolean isPayloadAvailable() {
         SpansCell pointer = min();
         do {
           if(pointer.isPayloadAvailable()) {
             return true;
           }
           pointer = pointer.next;
         } while(pointer.next != null);
      
         return false;
        }
      

      "Fixed" isPayloadAvailable()

       public boolean isPayloadAvailable() {
         SpansCell pointer = min();
         while (pointer != null) {
           if(pointer.isPayloadAvailable()) {
             return true;
           }
           pointer = pointer.next;
         }
      
         return false;
        }
      

      Exception produced:

        [junit] java.lang.NullPointerException
          [junit]     at org.apache.lucene.search.spans.NearSpansUnordered$SpansCell.access$300(NearSpansUnordered.java:65)
          [junit]     at org.apache.lucene.search.spans.NearSpansUnordered.isPayloadAvailable(NearSpansUnordered.java:235)
          [junit]     at org.apache.lucene.search.spans.NearSpansOrdered.shrinkToAfterShortestMatch(NearSpansOrdered.java:246)
          [junit]     at org.apache.lucene.search.spans.NearSpansOrdered.advanceAfterOrdered(NearSpansOrdered.java:154)
          [junit]     at org.apache.lucene.search.spans.NearSpansOrdered.next(NearSpansOrdered.java:122)
          [junit]     at org.apache.lucene.search.spans.SpanScorer.next(SpanScorer.java:54)
          [junit]     at org.apache.lucene.search.Scorer.score(Scorer.java:57)
          [junit]     at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:137)
          [junit]     at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:113)
          [junit]     at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:113)
          [junit]     at org.apache.lucene.search.Hits.<init>(Hits.java:80)
          [junit]     at org.apache.lucene.search.Searcher.search(Searcher.java:50)
          [junit]     at org.apache.lucene.search.Searcher.search(Searcher.java:40)
          [junit]     at com.attivio.lucene.SpanQueryTest.search(SpanQueryTest.java:79)
          [junit]     at com.attivio.lucene.SpanQueryTest.assertHitCount(SpanQueryTest.java:75)
          [junit]     at com.attivio.lucene.SpanQueryTest.test(SpanQueryTest.java:67)
      

      will attach unit test that causes exception (and passes with updated isPayloadAvailable())

        Activity

        Hide
        Tim Smith added a comment -

        unit test that causes exception attached

        Show
        Tim Smith added a comment - unit test that causes exception attached
        Hide
        Michael McCandless added a comment -

        I can confirm this... I'll commit to 2.4 & 2.9. Thanks Tim!

        Show
        Michael McCandless added a comment - I can confirm this... I'll commit to 2.4 & 2.9. Thanks Tim!
        Hide
        Michael McCandless added a comment -

        Committed revision 698487 on trunk and 698488 on 2.4 branch. Thanks Tim!

        Show
        Michael McCandless added a comment - Committed revision 698487 on trunk and 698488 on 2.4 branch. Thanks Tim!

          People

          • Assignee:
            Michael McCandless
            Reporter:
            Tim Smith
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development