Class ResponseInputStream<ResponseT>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Releasable
,Abortable
NOTE: You must read this stream promptly to avoid automatic cancellation. The default timeout for reading is 60
seconds, which starts when the response stream is ready. If read()
is not invoked before the timeout, the stream will
automatically abort to prevent resource leakage.
The timeout can be customized by passing a Duration
to the constructor, or disabled entirely by
passing Duration.ZERO
or a negative Duration
.
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 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 all of the http body before releasing
the connection which may add latency.
If it is not desired to read remaining data from the stream, you can explicitly abort the connection via 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.
The Url Connection and Crt http clients are not subject to this behaviour so the close
and
abort
methods will behave similarly with them.
-
Constructor Summary
ConstructorsConstructorDescriptionResponseInputStream
(ResponseT resp, InputStream in) ResponseInputStream
(ResponseT resp, InputStream in, Duration timeout) ResponseInputStream
(ResponseT resp, AbortableInputStream in) ResponseInputStream
(ResponseT resp, AbortableInputStream in, Duration timeout) -
Method Summary
Methods inherited from class software.amazon.awssdk.core.io.SdkFilterInputStream
available, close, mark, markSupported, release, reset, skip
-
Constructor Details
-
ResponseInputStream
-
ResponseInputStream
-
ResponseInputStream
-
ResponseInputStream
-
-
Method Details
-
response
- Returns:
- The unmarshalled POJO response associated with this content.
-
read
- Overrides:
read
in classSdkFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classSdkFilterInputStream
- Throws:
IOException
-
abort
-
hasTimeoutTask
public boolean hasTimeoutTask() -
timeoutTaskDoneOrCancelled
public boolean timeoutTaskDoneOrCancelled()
-