You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/10/11 12:29:00 UTC

[jira] [Commented] (LANG-1753) StringUtils.replaceEachRepeatedly regression in 3.11+

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

Gary D. Gregory commented on LANG-1753:
---------------------------------------

Hello [~km11]

Thank you for your report.

Would you be able to create a PR on GitHub to fix the issue and include a test to make sure a regression is not possible?


> StringUtils.replaceEachRepeatedly regression in 3.11+
> -----------------------------------------------------
>
>                 Key: LANG-1753
>                 URL: https://issues.apache.org/jira/browse/LANG-1753
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.11, 3.17.0
>            Reporter: Karakó Miklós
>            Priority: Major
>
> The following test fails with Commons Lang 3.11 and 3.17.0:
> {code}
> assertThrows(
>     IllegalStateException.class,
>     () -> StringUtils.replaceEachRepeatedly("%{key1}",
>         new String[] {"%{key1}", "%{key2}", "%{key3}"},
>         new String[] {"Key1 %{key2}", "Key2 %{key3}", "Key3 %{key1}"}),
>     "Should be a circular reference");
> {code}
> While it throws the expected IllegalStateException with 3.10.
> This commit seems to be related: https://github.com/apache/commons-lang/commit/d62d4e21ef20ee01e65cbf5257e04d6b572aa73b
> These also produce weird results with 3.11 and 3.17.0:
> {code}
> // fails, returns "bllaan" instead of "blaan"
> // similar to the already existing test in StringUtilsTest
> assertEquals("blaan", StringUtils.replaceEachRepeatedly("bllllaan", new String[]{"llaan"}, new String[]{"laan"}));
> {code}
> {code}
> // fails, returns "aab" instead of "ab"
> assertEquals("ab", StringUtils.replaceEachRepeatedly("aaaab", new String[] {"aab"}, new String[] {"ab"}));
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)