Skip to content

[SPARK-57427][CORE] Improve UTF8String bounds checks with Objects.checkIndex#56489

Closed
dongjoon-hyun wants to merge 2 commits into
apache:masterfrom
dongjoon-hyun:SPARK-57427
Closed

[SPARK-57427][CORE] Improve UTF8String bounds checks with Objects.checkIndex#56489
dongjoon-hyun wants to merge 2 commits into
apache:masterfrom
dongjoon-hyun:SPARK-57427

Conversation

@dongjoon-hyun

@dongjoon-hyun dongjoon-hyun commented Jun 13, 2026

Copy link
Copy Markdown
Member

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)

@dongjoon-hyun

Copy link
Copy Markdown
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>
@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Merged to master/4.x.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-57427 branch June 14, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants