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

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development