[ 
https://issues.apache.org/jira/browse/TEXT-239?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved TEXT-239.
----------------------------------
    Fix Version/s: 1.15.1
       Resolution: Fixed

[~iponomarev] 

Thank you for your report.

The fix is in git master, and 1.15.1-SNAPSHOT builds in 
[https://repository.apache.org/content/repositories/snapshots/]

Please verify your use case and close this ticket if appropriate.

 

> TextStringBuilder.append(char[], int, int) uses wrong variable in startIndex 
> exception message
> ----------------------------------------------------------------------------------------------
>
>                 Key: TEXT-239
>                 URL: https://issues.apache.org/jira/browse/TEXT-239
>             Project: Commons Text
>          Issue Type: Bug
>            Reporter: Ivan Ponomarev
>            Priority: Trivial
>             Fix For: 1.15.1
>
>
> {{TextStringBuilder.append(final char[] chars, final int startIndex, final 
> int length)}} throws {{StringIndexOutOfBoundsException}} when {{startIndex}} 
> is invalid, but the exception message incorrectly prints {{length}} instead 
> of {{startIndex}}:
> {code:java}
> if (startIndex < 0 || startIndex > chars.length) {
>     throw new StringIndexOutOfBoundsException("Invalid startIndex: " + 
> length);
> }
> {code}
> This appears to be a copy/paste issue (same bug exists in the deprecated 
> {{StrBuilder}} variants).
> h4.Proposed Fix
> Change the thrown message to use the correct variable:
> {code:java}
> throw new StringIndexOutOfBoundsException("Invalid startIndex: " + 
> startIndex);
> {code}
> h4.Also affected
> * deprecated `org.apache.commons.text.StrBuilder`
> * deprecated `org.apache.commons.lang3.text.StrBuilder`



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

Reply via email to