Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-7983

Utils.toUTF8 uses larger buffer than necessary for holding UTF8 data

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 5.4, 6.0
    • None
    • None

    Description

      Method in question:

      public static byte[] toUTF8(CharArr out) {
          byte[] arr = new byte[out.size() << 2]; // is 4x the real worst-case upper-bound?
          int nBytes = ByteUtils.UTF16toUTF8(out, 0, out.size(), arr, 0);
          return Arrays.copyOf(arr, nBytes);
        }
      

      The byte array should be at most out.size() * 3.

      Attachments

        Activity

          People

            shalin Shalin Shekhar Mangar
            shalin Shalin Shekhar Mangar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: