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

StrBuilder#replaceAll ArrayIndexOutOfBoundsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.1, 3.4, 3.5
    • 3.6
    • lang.text.*
    • None

    Description

      There is a bug in replace for StrBuilder, seems the use of nonupdated buffer and character count is off.

      new StrBuilder("Dear X, hello X.").replaceAll(StrMatcher.stringMatcher("X"), "012345678901234567");

      yields

      java.lang.ArrayIndexOutOfBoundsException: 49
      	at org.apache.commons.lang3.text.StrMatcher$StringMatcher.isMatch(StrMatcher.java:372)
      	at org.apache.commons.lang3.text.StrBuilder.replaceImpl(StrBuilder.java:2115)
      	at org.apache.commons.lang3.text.StrBuilder.replace(StrBuilder.java:2088)
      	at org.apache.commons.lang3.text.StrBuilder.replaceAll(StrBuilder.java:2049)
      

      Attachments

        Issue Links

          Activity

            People

              pascalschumacher Pascal Schumacher
              skotsj Andreas Skomedal
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: