Fix StringUtils.lastIndexOfAny start index by codingkiddo · Pull Request #20 · apache/empire-db (original) (raw)
Summary
Fixes an off-by-one error in StringUtils.lastIndexOfAny.
The method currently starts reverse iteration from value.length(), but the last valid character index is value.length() - 1. For non-empty strings, this can cause StringIndexOutOfBoundsException when value.charAt(i) is called.
Changes
- Start reverse iteration from
value.length() - 1 - Add unit tests for:
- matching the last character
- matching an earlier character
- no match
- empty string
- null input
Jira
I have requested access to Apache Jira, but the account approval is still pending. I am raising this PR first because the fix is small and straightforward.
Once my Jira account is approved, I can create/link the corresponding EMPIREDB Jira issue if required.
Verification
mvn -pl empire-db -Dtest=StringUtilsTest test mvn -pl empire-db test