简体   繁体   English

我应该关闭 S3Object 吗?

[英]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 an S3ObjectInputStream 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 calling getObject 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.

相关问题 使用 S3AsyncClient 从 AWS Java SDK 2 中的 GetObjectResponse 获取 S3Object InputStream? - Get an S3Object InputStream from a GetObjectResponse in AWS Java SDK 2 Using S3AsyncClient? 弃用 aws_s3_bucket_object 后,我是否应该仅使用 aws_s3_bucket 上传文件? - With aws_s3_bucket_object deprecated, should I upload files using aws_s3_bucket only? 我应该将 boolean 字段存储在 arrays 还是 object 中? - Should I store boolean fields in arrays or in an object? 我应该为我的文件使用 s3 存储桶还是应该只使用我的 ec2 实例 - Should I use an s3 bucket for my files or should I just stick to my ec2 instance 我应该如何为 Google Storage object 创建自定义解串器? - How should I create a custom deserializer for Google Storage object? 这个错误“null is not an object”是什么意思? 我该怎么办? - What does this error "null is not an object "mean? And what should I do? 我应该在哪里存储我的 object 在 AWS 运行 Ec2 实例与应用程序负载均衡器 - where should I store my object in AWS Running Ec2 Instance With Application Load balancer 将对象放入 AWS S3 时为什么要使用元数据? - Why should I use metadata when putting objects in AWS S3? 我应该提供什么以及如何配置 Terraform 远程 state S3 存储桶和 state 锁定 DynamoDB 表? - What and how should I provision Terraform remote state S3 bucket and state locking DynamoDB table? 使用 AWS 时,我应该在哪里上传我的应用程序文件? - Where should I upload my app's files while using AWS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM