[英]Should I close an S3Object?
It will be closed for my intention.它将因我的意图而关闭。
If you didn't close the S3Object
, it would lead to resource leaks.如果您不关闭
S3Object
,则会导致资源泄漏。
The S3Object
class should be closed to release the resources it holds, as it implements the Closeable
interface; S3Object
class 应该关闭以释放它持有的资源,因为它实现了Closeable
接口; resources, in this case, would be.network connection(s) to Amazon S3.在这种情况下,资源将是与 Amazon S3 的网络连接。
This is also explained in the AWS Developer Blog : AWS 开发人员博客中也对此进行了解释:
S3Object
contains anS3ObjectInputStream
that lets you stream down your data over the HTTP connection from Amazon S3.S3Object
包含一个S3ObjectInputStream
,可让您通过来自 Amazon S3 的 HTTP 连接下载数据 stream。 Since the HTTP connection is open and waiting, it's important to read the stream quickly after callinggetObject
and to remember to close the stream so that the HTTP connection can be released properly.由于HTTP连接处于开启等待状态,调用
getObject
后要快速读取stream,记得关闭stream,这样HTTP连接才能正常释放。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.