Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1753

StringUtils.replaceEachRepeatedly regression in 3.11+

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.11, 3.17.0
    • 3.18.0
    • lang.*
    • None

    Description

      The following test fails with Commons Lang 3.11 and 3.17.0:

      assertThrows(
          IllegalStateException.class,
          () -> StringUtils.replaceEachRepeatedly("%{key1}",
              new String[] {"%{key1}", "%{key2}", "%{key3}"},
              new String[] {"Key1 %{key2}", "Key2 %{key3}", "Key3 %{key1}"}),
          "Should be a circular reference");
      

      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:

      // 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"}));
      
      // fails, returns "aab" instead of "ab"
      assertEquals("ab", StringUtils.replaceEachRepeatedly("aaaab", new String[] {"aab"}, new String[] {"ab"}));
      

      Attachments

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              km11 Karakó Miklós
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: