Class IdempotentAsyncResponseHandler<T,R>

java.lang.Object
software.amazon.awssdk.core.internal.http.IdempotentAsyncResponseHandler<T,R>
Type Parameters:
T - The type of the wrapped TransformingAsyncResponseHandler
R - The type of the object used to determine scope.
All Implemented Interfaces:
TransformingAsyncResponseHandler<T>, SdkAsyncHttpResponseHandler

@ThreadSafe public class IdempotentAsyncResponseHandler<T,R> extends Object implements TransformingAsyncResponseHandler<T>
Wrapper for a TransformingAsyncResponseHandler that allows attachment to an external scope and given a way of evaluating whether that scope has changed or not will only allow prepare() to be called on its delegate once per state change and will cache and reserve the future that is returned by the delegate the rest of the time.

One application of this wrapper is to ensure that prepare() is not called on the underlying response handler more than once per retry no matter where or how many times its invoked.

This class is asserted to be thread-safe and it should be fine to have multiple threads call prepare() simultaneously.