[
https://issues.apache.org/jira/browse/LANG-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15163151#comment-15163151
]
NEGRO Eric commented on LANG-1207:
----------------------------------
Hello Loic,
Thank you for your fast reply. I'll wait the new release.
Regards,
> StringUtils.equals with CharSequence - IndexOutOfBoundsException
> ----------------------------------------------------------------
>
> Key: LANG-1207
> URL: https://issues.apache.org/jira/browse/LANG-1207
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.4
> Reporter: NEGRO Eric
> Fix For: 3.5
>
>
> Good day,
> This is my first report here, so I'm really sorry if I did not fill in the
> form right .
> I just ran into a bug with the method
> *public static boolean equals(final CharSequence cs1, final CharSequence
> cs2)*.
> If one of the object is not the String object, the method use the
> CharSequenceUtils to check the equality.
> The problem is that using Math.max(cs1.length(), cs2.length()) give the max
> length of the 2 objects. Then 1 of the object throw
> *IndexOutOfBoundsException*.
> I think it will be better to check the size before using CharSequenceUtils as
> the method equalsIgnoreCase.
> Maybe this code could correct the bug :
> if (cs1 == cs2) {
> return true;
> } else if (cs1 == null || cs2 == null) {
> return false;
> } else if (cs1.length() != cs2.length()) {
> return false;
> } else if (cs1 instanceof String && cs2 instanceof String) {
> return cs1.equals(cs2);
> } else {
> return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0,
> cs1.length());
> }
> Kind regards,
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)