Skip to content

Commit eeee238

Browse files
authored
Response input stream javadoc improvement (#5671)
* Improve ResponseInputStream javadoc about close/abort regarding connection pooling * mention specific http clients
1 parent 4a44a0f commit eeee238

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/ResponseInputStream.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@
2525

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

0 commit comments

Comments
 (0)