Home > Blockchain >  Should I close an S3Object?
Should I close an S3Object?

Time:01-09

It will be closed for my intention.

CodePudding user response:

If you didn't close the S3Object, it would lead to resource leaks.

The S3Object class should be closed to release the resources it holds, as it implements the Closeable interface; resources, in this case, would be network connection(s) to Amazon S3.

This is also explained in the AWS Developer Blog:

S3Object contains an S3ObjectInputStream that lets you stream down your data over the HTTP connection from Amazon S3. Since the HTTP connection is open and waiting, it’s important to read the stream quickly after calling getObject and to remember to close the stream so that the HTTP connection can be released properly.

  • Related