Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-21371

Make NonSyncByteArrayOutputStream Overflow Conscious

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.0, 4.0.0
    • 4.0.0-alpha-1
    • None
    • None

    Description

      NonSyncByteArrayOutputStream
        private int enLargeBuffer(int increment) {
          int temp = count + increment;
          int newLen = temp;
          if (temp > buf.length) {
            if ((buf.length << 1) > temp) {
              newLen = buf.length << 1;
            }
            byte newbuf[] = new byte[newLen];
            System.arraycopy(buf, 0, newbuf, 0, count);
            buf = newbuf;
          }
          return newLen;
        }
      

      This will fail if the array is 2GB or larger because it will double the size every time without consideration for the 4GB limit on arrays.

      Attachments

        1. HIVE-21371.2.patch
          2 kB
          David Mollitor
        2. HIVE-21371.1.patch
          2 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: