Wim Deblauwe
Wim Deblauwe

Reputation: 26878

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.

Upvotes: 7

Views: 2609

Answers (1)

guest
guest

Reputation: 11

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?

Upvotes: 1

Related Questions