Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to close InputStream after putObject() for Amazon Java SDK?

Is it needed to close the passed in InputStream on the putObject method of the Amazon Java SDK for S3?

Their example only shows usage with a File, but not with an InputStream. The Javadoc also does not indicate if it is needed or not.

like image 694
Wim Deblauwe Avatar asked Aug 15 '26 11:08

Wim Deblauwe


1 Answers

In the case of the S3 client, a provided InputStream is not closed by the call.

The relevant code is S3DataSource.Utils.cleanupDataSource(), which is called in a finally block for PutObject and similar calls.

This is a general Java convention, but since it's not documented there's no guarantee that it will remain this way. Perhaps file feedback?

like image 166
guest Avatar answered Aug 18 '26 02:08

guest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!