You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Maik Igloffstein (JIRA)" <ji...@apache.org> on 2015/05/05 12:06:59 UTC
[jira] [Created] (GROOVY-7413) String.replaceFirst - bad behavior
for null objects
Maik Igloffstein created GROOVY-7413:
----------------------------------------
Summary: String.replaceFirst - bad behavior for null objects
Key: GROOVY-7413
URL: https://issues.apache.org/jira/browse/GROOVY-7413
Project: Groovy
Issue Type: Bug
Components: groovy-runtime
Environment: *
Reporter: Maik Igloffstein
h3. Unit-Tests
{code}
assert "tEst" == "test".replaceFirst("e", "E");
assert "tEst" == "test".replaceFirst("e", null); //throws: java.lang.NullPointerException
assert "tEst" == "test".replaceFirst(null, "E");//throws: java.lang.NullPointerException
assert "tEst" == "test".replaceFirst(null, null);//throws: java.lang.NullPointerException
{code}
h3. Solutions
In my private opinion, throwing a null pointer exception isn't the best way here.
possible Solutions:
* IllegalArgumentException
* no replacement - just return and do nothing
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)