/** * {@inheritDoc} * * Delegates to {@link S3ObjectInputStream#abort()} if there is any data * remaining in the stream. Otherwise, it safely closes the stream. * * @see {@link S3ObjectInputStream#abort()} */ @Override public void close() throws IOException { if (_readAllBytes() || isAborted()) { super.close(); } else { LOG.warn( "Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and " + "may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input " + "stream after use."); if (httpRequest != null) { httpRequest.abort(); } IOUtils.closeQuietly(in, null); } }
@Override public synchronized long skip(long n) throws IOException { try { long skipped = super.skip(n); if (skipped > 0) { bytesRead += skipped; } return skipped; } catch (Exception e) { return onException(e); } }
/** * {@inheritDoc} */ @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * {@inheritDoc} * * Delegates to {@link S3ObjectInputStream#abort()} if there is any data * remaining in the stream. Otherwise, it safely closes the stream. * * @see {@link S3ObjectInputStream#abort()} */ @Override public void close() throws IOException { if (readAllBytes() || isAborted()) { super.close(); } else { LOG.warn( "Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and " + "may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input " + "stream after use."); if (httpRequest != null) { httpRequest.abort(); } IOUtils.closeQuietly(in, null); } }
new S3AbortableInputStream(is, httpRequest, s3Object.getObjectMetadata().getContentLength()); s3Object.setObjectContent(new S3ObjectInputStream(abortableInputStream, httpRequest, false)); return s3Object;
private S3AbortableInputStream abortableIs(HttpResponse response) { return new S3AbortableInputStream(response.getContent(), response.getHttpRequest(), getContentLength(response)); }
/** * {@inheritDoc} */ @Override public int read() throws IOException { try { int value = super.read(); eofReached = value == -1; if (!eofReached) { bytesRead++; } return value; } catch (Exception e) { return onException(e); } }
/** * {@inheritDoc} */ @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) throws IOException { try { int value = super.read(b, off, len); eofReached = value == -1; if (!eofReached) { bytesRead += value; } return value; } catch (Exception e) { return onException(e); } }
@Override public synchronized long skip(long n) throws IOException { try { long skipped = super.skip(n); if (skipped > 0) { bytesRead += skipped; } return skipped; } catch (Exception e) { return onException(e); } }
/** * {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) throws IOException { try { int value = super.read(b, off, len); eofReached = value == -1; if (!eofReached) { bytesRead += value; } return value; } catch (Exception e) { return onException(e); } }
/** * {@inheritDoc} */ @Override public int read() throws IOException { try { int value = super.read(); eofReached = value == -1; if (!eofReached) { bytesRead++; } return value; } catch (Exception e) { return onException(e); } }