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

Ivan Ponomarev closed TEXT-239.
-------------------------------

> 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