commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabian Lange (JIRA)" <j...@apache.org>
Subject [jira] Created: (LANG-552) StringUtils replaceEach - Bug or Missing Documentation
Date Mon, 09 Nov 2009 12:42:32 GMT
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


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.


Mime
View raw message