Enable skip methods on retrying inputstreams (#96337)

Currently we have a number of input streams that specifically override
the skip() method disabling the ability to skip bytes. In each case the
skip implementation works as we have properly implemented the
read(byte[]) methods used to discard bytes. However, we appear to have
disabled it as it would be possible to retry from the end of a skip if
there is a failure in the middle. At this time, that optimization is not
really necessary, however, we sporadically used skip so it would be nice
for the IS to support the method. This commit enables the super.skip()
and adds a comment about future optimizations.
This commit is contained in:
Tim Brooks 2023-05-25 10:11:27 -06:00 committed by GitHub
parent 3c5d96d2eb
commit ac829edc55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 11 deletions

View file

@ -765,11 +765,6 @@ public class AzureBlobStore implements BlobStore {
} }
} }
@Override
public long skip(long n) {
throw new UnsupportedOperationException("skip is not supported");
}
private void releaseByteBuf(ByteBuf buf) { private void releaseByteBuf(ByteBuf buf) {
ReferenceCountUtil.safeRelease(buf); ReferenceCountUtil.safeRelease(buf);
this.byteBuf = null; this.byteBuf = null;

View file

@ -246,8 +246,10 @@ class GoogleCloudStorageRetryingInputStream extends InputStream {
} }
@Override @Override
public long skip(long n) { public long skip(long n) throws IOException {
throw new UnsupportedOperationException("GoogleCloudStorageRetryingInputStream does not support seeking"); // This could be optimized on a failure by re-opening stream directly to the preferred location. However, it is rarely called,
// so for now we will rely on the default implementation which just discards bytes by reading.
return super.skip(n);
} }
@Override @Override

View file

@ -225,8 +225,10 @@ class S3RetryingInputStream extends InputStream {
} }
@Override @Override
public long skip(long n) { public long skip(long n) throws IOException {
throw new UnsupportedOperationException("S3RetryingInputStream does not support seeking"); // This could be optimized on a failure by re-opening stream directly to the preferred location. However, it is rarely called,
// so for now we will rely on the default implementation which just discards bytes by reading.
return super.skip(n);
} }
@Override @Override

View file

@ -112,8 +112,10 @@ class RetryingHttpInputStream extends InputStream {
} }
@Override @Override
public long skip(long n) { public long skip(long n) throws IOException {
throw new UnsupportedOperationException("RetryingHttpInputStream does not support seeking"); // This could be optimized on a failure by re-opening stream directly to the preferred location. However, it is rarely called,
// so for now we will rely on the default implementation which just discards bytes by reading.
return super.skip(n);
} }
@Override @Override