Uploaded image for project: 'Commons Codec'
  1. Commons Codec
  2. CODEC-229

StringUtils.newStringxxx(null) should return null, not NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10
    • 1.11
    • None

    Description

      Method calls such as StringUtils.newStringIso8859_1(null) should return null, not NPE.

      It looks like this capability was lost with the fix for CODEC-136, i.e.
      http://svn.apache.org/viewvc?rev=1306366&view=rev

      Several methods were changed from

      return StringUtils.newString(bytes, CharEncoding.xxx);
      to
      return new String(bytes, Charsets.xxx);
      

      The new code should have been:

      return newString(bytes, Charsets.xxx);
      

      The newString method handles null input.

      There were no tests for null input so the change in behaviour was missed.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: