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

   <!-- No issue: minor parity bug fix, issue not required -->
   
   ## Summary
   
   - `ADLSInputStream.readTail(buffer, offset, length)` computes the read start 
as `fileSize - length`. When the requested tail `length` exceeds the file size, 
that start goes negative and Azure SDK `FileRange` rejects it with 
`IllegalArgumentException`, so reading the tail of a small file fails.
   - Clamp the start to `0` with `Math.max(0, fileSize - length)`, so the whole 
file is read and the actual number of bytes read is returned, per the 
`RangeReadable.readTail` contract.
   - This matches the sibling `GCSInputStream.readTail`, which already clamps 
the same way 
(`gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSInputStream.java`). 
`S3InputStream` is unaffected because it uses an HTTP suffix range 
(`bytes=-{length}`).
   - Reached in practice through `ParquetIO`, which delegates `readTail` to the 
cloud stream when prefetching the Parquet footer of a small file.
   
   ## Testing done
   
   - Added `TestADLSInputStream#testReadTailLengthLargerThanFileSize`, 
asserting a `readTail` with `length` greater than the file size reads the whole 
file and returns its size (fails before the fix).
   - `./gradlew :iceberg-azure:test --tests 
"org.apache.iceberg.azure.adlsv2.TestADLSInputStream"` — 5 tests passed.
   - `./gradlew :iceberg-azure:spotlessCheck :iceberg-azure:checkstyleMain 
:iceberg-azure:checkstyleTest` — passed.
   - Full `:iceberg-azure:check` not run locally: it pulls Azurite/Docker 
integration tests. Unit tests, spotless, and checkstyle were run separately.
   


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