barry3406 opened a new pull request, #15926:
URL: https://github.com/apache/iceberg/pull/15926

   ## Summary
   
   - `FileRange` constructor validates `length()` and `offset()` (getters) 
before assigning fields, so negative inputs bypass validation silently since 
field defaults are 0
   - Changed to validate constructor parameters directly instead of getters
   - Added `TestFileRange.java` with test cases for negative offset, negative 
length, null byteBuffer, and valid construction
   
   ## Root Cause
   
   ```java
   // BEFORE — length() returns 0 (field default), not the parameter value
   Preconditions.checkArgument(
       length() >= 0, "Invalid length: %s in range (must be >= 0)", length);
   
   // AFTER — validates the actual parameter
   Preconditions.checkArgument(
       length >= 0, "Invalid length: %s in range (must be >= 0)", length);
   ```
   
   ## Test Plan
   
   - [x] Added `TestFileRange.java` covering negative offset, negative length, 
null byteBuffer, and valid range
   - [ ] Existing CI tests should pass
   
   Fixes #15922


-- 
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]

Reply via email to