Skip to content

Commit

Permalink
Response input stream javadoc improvement (#5671)
Browse files Browse the repository at this point in the history
* Improve ResponseInputStream javadoc about close/abort regarding connection pooling

* mention specific http clients
  • Loading branch information
L-Applin authored Oct 18, 2024
1 parent 4a44a0f commit eeee238
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@

/**
* Input stream that provides access to the unmarshalled POJO response returned by the service in addition to the streamed
* contents. This input stream should be closed to release the underlying connection back to the connection pool.
*
* contents. This input stream should be closed after all data has been read from the stream.
* <p>
* Note about the Apache http client: This input stream can be used to leverage a feature of the Apache http client where
* connections are released back to the connection pool to be reused. As such, calling {@link ResponseInputStream#close() close}
* on this input stream will result in reading the remaining data from the stream and leaving the connection open, even if the
* stream was only partially read from. For large http payload, this means reading <em>all</em> of the http body before releasing
* the connection which may add latency.
* <p>
* If it is not desired to read remaining data from the stream, you can explicitly abort the connection via {@link #abort()}
* instead. This will close the underlying connection and require establishing a new HTTP connection on subsequent requests which
* may outweigh the cost of reading the additional data.
* <p>
* If it is not desired to read remaining data from the stream, you can explicitly abort the connection via {@link #abort()}.
* Note that this will close the underlying connection and require establishing an HTTP connection which may outweigh the
* cost of reading the additional data.
* </p>
* The Url Connection and Crt http clients are not subject to this behaviour so the {@link ResponseInputStream#close() close} and
* {@link ResponseInputStream#abort() abort} methods will behave similarly with them.
*/
@SdkPublicApi
public final class ResponseInputStream<ResponseT> extends SdkFilterInputStream implements Abortable {
Expand Down

0 comments on commit eeee238

Please sign in to comment.