[
https://issues.apache.org/jira/browse/LANG-1406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16839056#comment-16839056
]
Gerardo Torres Ontiveros commented on LANG-1406:
------------------------------------------------
This error happens in StringUtils.replace and can be fixed using
StringUtils.indexOfIgnoreCase instead of converting first to lower case with
the native String method and using the String native indexOf method.
The method StringUtils.indexOfIgnoreCase resolves the problem because converts
and compare the characters individually.
But will be some consequences to using indexOfIgnoreCase because is not Locale
sensitive, it uses Character.toLowerCase() that is not Locale sensitive as
String.toLowerCase(). Thus Turkish words or other language words could be
treated incorrectly.
The solution I pose i to change the use of Character.toLowerCase to
String.toLowerCase and upperCase in order to handle the Strings with a Locale.
> StringIndexOutOfBoundsException in StringUtils.replaceIgnoreCase
> ----------------------------------------------------------------
>
> Key: LANG-1406
> URL: https://issues.apache.org/jira/browse/LANG-1406
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Reporter: Michael Ryan
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> STEPS TO REPRODUCE:
> {code}
> StringUtils.replaceIgnoreCase("\u0130x", "x", "")
> {code}
> EXPECTED: "\u0130" is returned.
> ACTUAL: StringIndexOutOfBoundsException
> This happens because the replace method is assuming that text.length() ==
> text.toLowerCase().length(), which is not true for certain characters.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)