Azure: Fix ADLSInputStream.readTail for length over file size#16883
Open
thswlsqls wants to merge 1 commit into
Open
Azure: Fix ADLSInputStream.readTail for length over file size#16883thswlsqls wants to merge 1 commit into
thswlsqls wants to merge 1 commit into
Conversation
When the requested tail length exceeds the file size, readStart became negative and Azure SDK FileRange rejected it with IllegalArgumentException, so reading the tail of a small file failed. Clamp the start position to 0, matching GCSInputStream.readTail, so the whole file is read and the actual number of bytes read is returned per the RangeReadable.readTail contract. Generated-by: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ADLSInputStream.readTail(buffer, offset, length)computes the read start asfileSize - length. When the requested taillengthexceeds the file size, that start goes negative and Azure SDKFileRangerejects it withIllegalArgumentException, so reading the tail of a small file fails.0withMath.max(0, fileSize - length), so the whole file is read and the actual number of bytes read is returned, per theRangeReadable.readTailcontract.GCSInputStream.readTail, which already clamps the same way (gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSInputStream.java).S3InputStreamis unaffected because it uses an HTTP suffix range (bytes=-{length}).ParquetIO, which delegatesreadTailto the cloud stream when prefetching the Parquet footer of a small file.Testing done
TestADLSInputStream#testReadTailLengthLargerThanFileSize, asserting areadTailwithlengthgreater 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.:iceberg-azure:checknot run locally: it pulls Azurite/Docker integration tests. Unit tests, spotless, and checkstyle were run separately.AI Disclosure