LuciferYang opened a new issue, #1098:
URL: https://github.com/apache/arrow-java/issues/1098
### Describe the bug
In `LargeListVector.setValueCount()`, the precondition check that validates
`childValueCount` before casting from `long` to `int` uses `||` instead of
`&&`, making the condition always evaluate to `true`:
```java
Preconditions.checkArgument(
childValueCount <= Integer.MAX_VALUE || childValueCount >=
Integer.MIN_VALUE,
"LargeListVector doesn't yet support 64-bit allocations: %s",
childValueCount);
```
For any `long` value `x`, at least one of `x <= Integer.MAX_VALUE` or `x >=
Integer.MIN_VALUE` is always true (their union covers the entire `long` range),
so the check never rejects any value.
This means:
- A `childValueCount` exceeding `Integer.MAX_VALUE` silently truncates when
cast to `(int)`, causing data corruption
- A negative `childValueCount` (from corrupted offset data) is silently
passed through
### Expected behavior
The check should use `&&` with a lower bound of `0` (since `childValueCount`
represents element count and must be non-negative):
```java
Preconditions.checkArgument(
childValueCount <= Integer.MAX_VALUE && childValueCount >= 0,
"LargeListVector doesn't yet support 64-bit allocations: %s",
childValueCount);
```
This is consistent with the correct implementation in
`LargeListViewVector.setValueCount()` (line 887-890).
### Component(s)
Java
--
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]