Skip to content

Commit

Permalink
Avoid unnecessary I/O when skipping in S3InputStream with unknown length
Browse files Browse the repository at this point in the history
  • Loading branch information
pettyjamesm committed Sep 19, 2023
1 parent f034b22 commit 1668ef3
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,8 @@ public void skipNBytes(long n)
return;
}

if (length == null) {
seekStream();
super.skipNBytes(n);
return;
}

long position = nextReadPosition + n;
if ((position < 0) || (position > length)) {
if ((position < 0) || (length != null && position > length)) {
throw new EOFException("Unable to skip %s bytes (position=%s, fileSize=%s): %s".formatted(n, nextReadPosition, length, location));
}
nextReadPosition = position;
Expand Down

0 comments on commit 1668ef3

Please sign in to comment.