You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2015/06/28 08:23:04 UTC

[jira] [Resolved] (GROOVY-7413) String.replaceFirst - bad behavior for null objects

     [ https://issues.apache.org/jira/browse/GROOVY-7413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Theodorou resolved GROOVY-7413.
--------------------------------------
    Resolution: Auto Closed
      Assignee: Jochen Theodorou

> 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
>            Assignee: Jochen Theodorou
>
> 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)