Lucene - Core
  1. Lucene - Core
  2. LUCENE-2119

If you pass Integer.MAX_VALUE as 2nd param to search(Query, int) you hit unexpected NegativeArraySizeException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.3, 3.0.2, 3.1, 4.0-ALPHA
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Note that this is a nonsense value to pass in, since our PQ impl allocates the array up front.

      It's because PQ takes 1+ this value (which wraps to -1), and attempts to allocate that. We should bounds check it, and drop PQ size by one in this case.

      Better, maybe: in IndexSearcher, if that n is ever > maxDoc(), set it to maxDoc().

      This trips users up fairly often because they assume our PQ doesn't statically pre-allocate (a reasonable assumption...).

      1. LUCENE-2119.patch
        3 kB
        Michael McCandless

        Activity

        Michael McCandless created issue -
        Hide
        Michael McCandless added a comment -

        Patch attached. In PQ if incoming size is Integer.MAX_VALUE, I don't try to +1 it. And, in IndexSearcher.search, when I create PQ, I now use min(nDocs, maxDoc()). I'll commit shortly.

        Show
        Michael McCandless added a comment - Patch attached. In PQ if incoming size is Integer.MAX_VALUE, I don't try to +1 it. And, in IndexSearcher.search, when I create PQ, I now use min(nDocs, maxDoc()). I'll commit shortly.
        Michael McCandless made changes -
        Field Original Value New Value
        Attachment LUCENE-2119.patch [ 12427090 ]
        Hide
        Michael McCandless added a comment -

        Thanks Paul!

        Show
        Michael McCandless added a comment - Thanks Paul!
        Michael McCandless made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Michael McCandless added a comment -

        backport

        Show
        Michael McCandless added a comment - backport
        Michael McCandless made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Michael McCandless made changes -
        Fix Version/s 2.9.3 [ 12314799 ]
        Michael McCandless made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 3.0.2 [ 12314798 ]
        Fix Version/s 3.1 [ 12314822 ]
        Resolution Fixed [ 1 ]
        Uwe Schindler made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12483926 ] Default workflow, editable Closed status [ 12564677 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12564677 ] jira [ 12584345 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development