@Override public void close() throws IOException { s3obj.close(); }
for (S3ObjectSummary objectSummary : current.getObjectSummaries()) { S3Object object = s3.getObject(new GetObjectRequest(bucketName, objectSummary.getKey())); System.out.println(object.getKey()); object.close(); }
/** * Download an object from S3. * * @param bucket * The name of the bucket * @param key * The file key of the object to upload/update. * @param result * The Hash map where data from the object are written * */ protected Status readFromStorage(String bucket, String key, Map<String, ByteIterator> result, SSECustomerKey ssecLocal) { try { S3Object object = getS3ObjectAndMetadata(bucket, key, ssecLocal); InputStream objectData = object.getObjectContent(); //consuming the stream // writing the stream to bytes and to results result.put(key, new ByteArrayByteIterator(IOUtils.toByteArray(objectData))); objectData.close(); object.close(); } catch (Exception e){ System.err.println("Not possible to get the object "+key); e.printStackTrace(); return Status.ERROR; } return Status.OK; }
fieldCount = sizeOfFile/sizeArray; totalSize = sizeOfFile; object.close(); } catch (Exception e){ System.err.println("Not possible to get the object :"+key);
@Override public void close() throws IOException { s3obj.close(); }
@Override public void close() throws IOException { if (s3Object != null) { s3Object.close(); } open = false; }
@Override public void close() throws IOException { wrapped.close(); }
@Override public void close() throws IOException { this.object.close(); }
@Override public void close() throws IOException { s3obj.close(); }
@Override public void close() throws IOException { s3obj.close(); }
public void close() { try { obj.close(); } catch (Exception e) { } try { in.close(); } catch (Exception e) { } }
@Override public synchronized void close() throws IOException { if (closed) { throw new IOException("Stream closed"); } super.close(); closed = true; if (wrappedObject != null) { wrappedObject.close(); } }
public BufferedImage getImage(String bucketName, String path) throws Exception { logger.debug("[GeoSparkViz][getImage] Start"); S3Object s3Object = s3client.getObject(bucketName, path); InputStream inputStream = s3Object.getObjectContent(); BufferedImage rasterImage = ImageIO.read(inputStream); inputStream.close(); s3Object.close(); logger.info("[GeoSparkViz][getImage] Got an image"); return rasterImage; } }
private void closeObject(S3Object object) throws StorageException { try { object.close(); } catch (IOException e) { throw new StorageException( "Error closing connection to " + object.getKey() + ": " + e.getMessage(), e); } }
private void closeObject(S3Object object) throws StorageException { try { object.close(); } catch (IOException e) { throw new StorageException( "Error closing connection to " + object.getKey() + ": " + e.getMessage(), e); } }
@Override public void close() { try { if(video.getS3Object() != null) { video.getS3Object().close(); } } catch (IOException e) { log.warning("Unable to close InputStream, this may lead to resource leaks!"); } } }
@Override public SeekableByteChannel position(long newPosition) throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } checkArgument(newPosition >= 0, "newPosition too low"); checkArgument(newPosition < contentLength, "new position too high"); if (newPosition == position) { return this; } // The position has changed, so close and destroy the object to induce a re-creation on the next // call to read() if (s3Object != null) { s3Object.close(); s3Object = null; } position = newPosition; return this; }
public boolean existsInS3(SciHubEntry entry) { String productInfoPath = L1CProductConstants.buildS3ProductInfoPath(settings.getS3ProductPathPrefix(), entry.getProductStopTime(), entry.getName()); try { logger.trace("Getting product info {} from s3", productInfoPath); S3Object s3Object = s3.getObject(settings.getS3BucketName(), productInfoPath); logger.trace("Getting product info {} from s3 done {}!", productInfoPath, s3Object!=null); boolean exists= s3Object != null ? true : false; s3Object.close(); return exists; } catch (Exception ex) { logger.trace("Getting product info {} from s3 failed!", productInfoPath); return false; } }
/** * ensureEverythingIsReleased as part of close process. */ public void ensureEverythingIsReleased() { if (this.isClosed) { return; } try { // ensure that the S3 Object is closed properly. this.s3Object.close(); } catch (Throwable ex) { LOGGER.warn("Problem Closing the S3Object[{}]: {}", s3Object.getKey(), ex.getMessage()); } try { // Abort the stream this.is.abort(); } catch (Throwable ex) { LOGGER.warn("Problem Aborting S3Object[{}]: {}", s3Object.getKey(), ex.getMessage()); } // close the input Stream Safely closeSafely(this.is); // This corrects the issue with Open HTTP connections closeSafely(this.s3Object); this.isClosed = true; }
@Override public void run() { try { obj = s3Service.getObject(req); in = new DataInputStream(obj.getObjectContent()); in.readFully(b); l.commandResponse(this); } catch (AmazonS3Exception e) { if (e.getErrorCode().equalsIgnoreCase("InvalidObjectState")) l.setDAR(new DataArchivedException()); l.commandException(e); } catch (Exception e) { // SDFSLogger.getLog().debug("unable to read " + obj.getKey() + // " at pos=" + pos + " byte len=" + b.length + " file size=" // +obj.getObjectMetadata().getContentLength(),e); l.commandException(e); } finally { try { obj.close(); } catch (Exception e) { } try { in.close(); } catch (Exception e) { } } }