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

Henri Yandell updated LANG-552:
-------------------------------

    Fix Version/s: 3.0

Agreed that at the least a javadoc update should be done. Whether to change 
code - something up for discussion.

Usually the null safe approach covers passing null directly in, rather than 
null inside an array.

> StringUtils replaceEach - Bug or Missing Documentation 
> -------------------------------------------------------
>
>                 Key: LANG-552
>                 URL: https://issues.apache.org/jira/browse/LANG-552
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Fabian Lange
>             Fix For: 3.0
>
>
> The following Test Case for replaceEach fails with a null pointer exception.
> I have expected that all StringUtils methods are "null-friendly"
> The use case is that i will stuff Values into the replacementList of which I 
> do not want to check whether they are null.
> I admit the use case is not perfect, because it is unclear what happens on 
> the replace.
> I outlined three expectations in the test case, of course only one should be 
> met.
> If it is decided that none of them should be possible, I propose to update 
> the documentation with what happens when null is passed as replacement string
> {code}
> import static org.junit.Assert.assertEquals;
> import org.apache.commons.lang.StringUtils;
> import org.junit.Test;
> public class StringUtilsTest {
>       @Test
>       public void replaceEach(){
>               String original = "Hello World!";
>               String[] searchList = {"Hello", "World"};
>               String[] replacementList = {"Greetings", null};
>               String result = StringUtils.replaceEach(original, searchList, 
> replacementList);
>               assertEquals("Greetings !", result);
>               //perhaps this is ok as well
>                 //assertEquals("Greetings World!", result);
>                 //or even
>               //assertEquals("Greetings null!", result);
>       }
>       
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to