uros-db commented on code in PR #47871:
URL: https://github.com/apache/spark/pull/47871#discussion_r1731165842
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationAwareUTF8String.java:
##########
@@ -671,6 +671,11 @@ public static int indexOf(final UTF8String target, final
UTF8String pattern,
// Initialize the string search with respect to the specified ICU
collation.
String targetStr = target.toValidString();
String patternStr = pattern.toValidString();
+ // Check if `start` is out of bounds. The provided offset `start` is given
in number of
+ // codepoints, so a simple `targetStr.length` check is not sufficient
here. This check is
+ // needed because `String.offsetByCodePoints` throws an
`IndexOutOfBoundsException`
+ // exception when the offset is out of bounds.
+ if (targetStr.codePointCount(0, targetStr.length()) <= start) return
MATCH_NOT_FOUND;
Review Comment:
```suggestion
if (targetStr.codePointCount(0, targetStr.length()) <= start) return
start;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]