Skip to content

GH-1098: [Java][Vector] Fix always-true precondition check in LargeListVector.setValueCount#1099

Open
LuciferYang wants to merge 1 commit intoapache:mainfrom
LuciferYang:fix-large-list-vector-precondition-logic
Open

GH-1098: [Java][Vector] Fix always-true precondition check in LargeListVector.setValueCount#1099
LuciferYang wants to merge 1 commit intoapache:mainfrom
LuciferYang:fix-large-list-vector-precondition-logic

Conversation

@LuciferYang
Copy link
Copy Markdown

What's Changed

Fix the precondition check in LargeListVector.setValueCount() where || made the condition always true (childValueCount <= Integer.MAX_VALUE || childValueCount >= Integer.MIN_VALUE is a tautology for any long value), allowing silent data corruption when childValueCount exceeds Integer.MAX_VALUE or is negative.

Changes:

  • Replace || with && and Integer.MIN_VALUE with 0 to correctly bound childValueCount to [0, Integer.MAX_VALUE], consistent with LargeListViewVector
  • Add rejection tests for negative and overflow childValueCount
  • Add positive boundary tests for zero, valid, and Integer.MAX_VALUE values

Closes #1098.

@github-actions

This comment has been minimized.

@LuciferYang
Copy link
Copy Markdown
Author

Could a maintainer please add the bug-fix label to this PR? I don't have label permissions on this repository. Thank you!

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Mar 30, 2026
@github-actions github-actions bot added this to the 20.0.0 milestone Mar 30, 2026
Copy link
Copy Markdown
Contributor

@ennuite ennuite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one. I looked into this: the bug has been there since the class was created, see 4deba44#diff-c3066ea815144f3e05b277c87cae8a7701f0f1481e15da508261664ab017d944R984
The PR fixes the bug and has test coverage for all equivalence classes. The correct values are in the interval [0, Integer.MAX_Value]; there are tests for a negative value, 0, a positive value smaller than Integer.MAX_Value, Integer.MAX_Value and a positive value greater than Integer.MAX_Value.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java][Vector] Always-true precondition check in LargeListVector.setValueCount allows silent data corruption

3 participants