[SPARK-57427][CORE] Improve UTF8String bounds checks with Objects.checkIndex#56489
Closed
dongjoon-hyun wants to merge 2 commits into
Closed
[SPARK-57427][CORE] Improve UTF8String bounds checks with Objects.checkIndex#56489dongjoon-hyun wants to merge 2 commits into
UTF8String bounds checks with Objects.checkIndex#56489dongjoon-hyun wants to merge 2 commits into
Conversation
peter-toth
approved these changes
Jun 14, 2026
Member
Author
|
Thank you, @peter-toth ! |
dongjoon-hyun
added a commit
that referenced
this pull request
Jun 14, 2026
…checkIndex` ### What changes were proposed in this pull request? Use `java.util.Objects.checkIndex(index, length)` (Java 9+) in place of the hand-written `index < 0 || index >= length` bounds checks in `UTF8String.getChar` and `UTF8String.codePointFrom`. ### Why are the changes needed? It replaces boilerplate with a single, intention-revealing JDK call. No functional change (the same `IndexOutOfBoundsException` is thrown). Additionally, this provides a better exception message than the current one, `new IndexOutOfBoundsException()`, in case of failure. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) Closes #56489 from dongjoon-hyun/SPARK-57427. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 4608e44) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Member
Author
|
Merged to master/4.x. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Use
java.util.Objects.checkIndex(index, length)(Java 9+) in place of thehand-written
index < 0 || index >= lengthbounds checks inUTF8String.getCharand
UTF8String.codePointFrom.Why are the changes needed?
It replaces boilerplate with a single, intention-revealing JDK call. No functional
change (the same
IndexOutOfBoundsExceptionis thrown).Additionally, this provides a better exception message than the current one,
new IndexOutOfBoundsException(), in case of failure.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Pass the CIs.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)