You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2010/02/25 20:50:28 UTC

[jira] Updated: (LANG-552) StringUtils replaceEach - Bug or Missing Documentation

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

Niall Pemberton updated LANG-552:
---------------------------------

    Fix Version/s:     (was: 3.0)
                   2.5

> StringUtils replaceEach - Bug or Missing Documentation 
> -------------------------------------------------------
>
>                 Key: LANG-552
>                 URL: https://issues.apache.org/jira/browse/LANG-552
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Fabian Lange
>             Fix For: 2.5
>
>
> 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.