commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CODEC-229) StringUtils.newStringxxx(null) should return null, not NPE
Date Sun, 26 Mar 2017 17:16:41 GMT
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)

Mime
View raw message