Uploaded image for project: '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

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.9.3, 3.0.2, 3.1, 4.0-ALPHA
    • core/search
    • None
    • 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...).

      Attachments

        1. LUCENE-2119.patch
          3 kB
          Michael McCandless

        Activity

          People

            mikemccand Michael McCandless
            mikemccand Michael McCandless
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: