Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,17 @@ private void seekStream(boolean forceStreamReset)
long skip = nextReadPosition - streamPosition;
if (skip <= max(getAvailable(), MAX_SKIP_BYTES)) {
// already buffered or seek is small enough
if (doSkip(skip) == skip) {
streamPosition = nextReadPosition;
return;
try {
if (in.skip(skip) == skip) {
streamPosition = nextReadPosition;
return;
}
}
Comment thread
electrum marked this conversation as resolved.
Comment thread
electrum marked this conversation as resolved.
catch (IOException _) {
// reopen the stream below at the requested position
}
catch (AbortedException e) {
Comment thread
electrum marked this conversation as resolved.
throw new InterruptedIOException();
}
}
}
Expand All @@ -221,11 +229,6 @@ private void seekStream(boolean forceStreamReset)
rangeRequest = request.toBuilder().range(range).build();
}
in = client.getObject(rangeRequest);
// a workaround for https://github.com/aws/aws-sdk-java-v2/issues/3538
if (in.response().contentLength() != null && in.response().contentLength() == 0) {
in.close();
in = new ResponseInputStream<>(in.response(), nullInputStream());
}
streamPosition = nextReadPosition;
}
catch (NoSuchKeyException e) {
Expand Down Expand Up @@ -274,17 +277,6 @@ private int getAvailable()
}
}

private long doSkip(long n)
throws IOException
{
try {
return in.skip(n);
}
catch (AbortedException e) {
throw new InterruptedIOException();
}
}

private int doRead()
throws IOException
{
Expand Down