You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2017/03/26 17:16:41 UTC

[jira] [Created] (CODEC-229) StringUtils.newStringxxx(null) should return null, not NPE

Sebb created CODEC-229:
--------------------------

             Summary: StringUtils.newStringxxx(null) should return null, not NPE
                 Key: CODEC-229
                 URL: https://issues.apache.org/jira/browse/CODEC-229
             Project: Commons Codec
          Issue Type: Bug
            Reporter: Sebb


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

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

The new code should have been:

{code}
return newString(bytes, Charsets.xxx);
{code}

The newString method handles null input.

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




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)