[ 
https://issues.apache.org/jira/browse/LANG-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005226#comment-13005226
 ] 

qed commented on LANG-686:
--------------------------

I solved this problem by making this call instead:

StringUtils.replaceEachRepeatedly("aaa", new String[]{"aa", ""}, new 
String[]{"aXa", ""});

Maybe there should be a limit to number of iterations or something similar. I 
didn't know that this function is not supposed to support recursion. I think 
this function is good suited when (java) regex fail in matching already 
replaced part of string and hence it shouldn't be dicouraged to use this 
function as a solution imho.

> StringUtils.replaceEachRepeatedly("aaa", new String[]{"aa"}, new 
> String[]{"aXa"}); throw an exception
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LANG-686
>                 URL: https://issues.apache.org/jira/browse/LANG-686
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.6
>         Environment: jdk 1.6.24, windows xp pro sp3, eclipse helios
>            Reporter: qed
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> After executing line
> StringUtils.replaceEachRepeatedly("aaa", new String[]{"aa"}, new 
> String[]{"aXa"});
> exception is thrown:
> Exception in thread "main" java.lang.IllegalStateException: TimeToLive of -1 
> is less than 0: aXaXa
>       at 
> org.apache.commons.lang.StringUtils.replaceEach(StringUtils.java:3986)
>       at 
> org.apache.commons.lang.StringUtils.replaceEach(StringUtils.java:4099)
>       at 
> org.apache.commons.lang.StringUtils.replaceEach(StringUtils.java:4099)
>       at 
> org.apache.commons.lang.StringUtils.replaceEachRepeatedly(StringUtils.java:3920)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to