Interface ExecutionInterceptor

    • Method Detail

      • modifyRequest

        default SdkRequest modifyRequest​(Context.ModifyRequest context,
                                         ExecutionAttributes executionAttributes)
        Modify an SdkRequest given to a service client before it is marshalled into an SdkHttpFullRequest.
        Parameters:
        context - The current state of the execution, including the current SDK request from the service client call.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified request that should be used for the rest of the execution. Must not be null.
      • beforeMarshalling

        default void beforeMarshalling​(Context.BeforeMarshalling context,
                                       ExecutionAttributes executionAttributes)
        Read the finalized request as it will be given to the marshaller to be converted into an SdkHttpFullRequest.
        Parameters:
        context - The current state of the execution, including the SDK request (potentially modified by other interceptors) from the service client call.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to
      • modifyHttpRequest

        default SdkHttpRequest modifyHttpRequest​(Context.ModifyHttpRequest context,
                                                 ExecutionAttributes executionAttributes)
        Modify the SdkHttpFullRequest before it is sent to the service.
        Parameters:
        context - The current state of the execution, including the SDK and current HTTP request.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified HTTP request that should be sent to the service. Must not be null.
      • beforeTransmission

        default void beforeTransmission​(Context.BeforeTransmission context,
                                        ExecutionAttributes executionAttributes)
        Read the finalized HTTP request as it will be sent to the HTTP client. This includes modifications made by other interceptors and the message signature. It is possible that the HTTP client could further modify the request, so debug- level wire logging should be trusted over the parameters to this method.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines a request failure is retriable, this will be invoked for each retry attempt.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP request (potentially modified by other interceptors) to be sent to the downstream service.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to
      • afterTransmission

        default void afterTransmission​(Context.AfterTransmission context,
                                       ExecutionAttributes executionAttributes)
        Read the HTTP response as it was returned by the HTTP client, before it is modified by other interceptors. beforeUnmarshalling(software.amazon.awssdk.core.interceptor.Context.BeforeUnmarshalling, software.amazon.awssdk.core.interceptor.ExecutionAttributes) should be used in most circumstances for reading the HTTP response because it includes modifications made by other interceptors.

        It is possible that the HTTP client could have already modified this response, so debug-level wire logging should be trusted over the parameters to this method.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines the error code returned by the service is retriable, this will be invoked for each response returned by the service.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests and the unmodified HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to
      • modifyHttpResponse

        default SdkHttpResponse modifyHttpResponse​(Context.ModifyHttpResponse context,
                                                   ExecutionAttributes executionAttributes)
        Modify the SdkHttpFullRequest before it is unmarshalled into an SdkResponse.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines the error code returned by the service is retriable, this will be invoked for each response returned by the service.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests and the current HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified HTTP response that should be given to the unmarshaller. Must not be null.
      • modifyAsyncHttpResponseContent

        default Optional<org.reactivestreams.Publisher<ByteBuffer>> modifyAsyncHttpResponseContent​(Context.ModifyHttpResponse context,
                                                                                                   ExecutionAttributes executionAttributes)
        Modify the SdkHttpFullRequest before it is unmarshalled into an SdkResponse.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines the error code returned by the service is retriable, this will be invoked for each response returned by the service.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests and the current HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified HTTP response that should be given to the unmarshaller. Must not be null.
      • modifyHttpResponseContent

        default Optional<InputStream> modifyHttpResponseContent​(Context.ModifyHttpResponse context,
                                                                ExecutionAttributes executionAttributes)
        Modify the SdkHttpFullRequest before it is unmarshalled into an SdkResponse.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines the error code returned by the service is retriable, this will be invoked for each response returned by the service.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests and the current HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified HTTP response that should be given to the unmarshaller. Must not be null.
      • beforeUnmarshalling

        default void beforeUnmarshalling​(Context.BeforeUnmarshalling context,
                                         ExecutionAttributes executionAttributes)
        Read the finalized HTTP response as it will be given to the unmarshaller to be converted into an SdkResponse.

        Note: Unlike many other lifecycle methods, this one may be invoked multiple times. If the RetryPolicy determines the error code returned by the service is retriable, this will be invoked for each response returned by the service.

        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests as well as the (potentially modified by other interceptors) HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
      • modifyResponse

        default SdkResponse modifyResponse​(Context.ModifyResponse context,
                                           ExecutionAttributes executionAttributes)
        Modify the SdkResponse before it is returned by the client.
        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests as well as the SDK and HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        The potentially-modified SDK response that should be returned by the client. Must not be null.
      • afterExecution

        default void afterExecution​(Context.AfterExecution context,
                                    ExecutionAttributes executionAttributes)
        Read the finalized SdkResponse as it will be returned by the client invocation.
        Parameters:
        context - The current state of the execution, including the SDK and HTTP requests as well as the SDK and HTTP response.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
      • modifyException

        default Throwable modifyException​(Context.FailedExecution context,
                                          ExecutionAttributes executionAttributes)
        Modify the exception before it is thrown.

        This will only be invoked if the entire execution fails. If a retriable error happens (according to the RetryPolicy) and a subsequent retry succeeds, this method will not be invoked.

        Parameters:
        context - The context associated with the execution that failed. An SDK request will always be available, but depending on the time at which the failure happened, the HTTP request, HTTP response and SDK response may not be available. This also includes the exception that triggered the failure.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.
        Returns:
        the modified Exception
      • onExecutionFailure

        default void onExecutionFailure​(Context.FailedExecution context,
                                        ExecutionAttributes executionAttributes)
        Invoked when any error happens during an execution that prevents the request from succeeding. This could be due to an error returned by a service call, a request timeout or even another interceptor raising an exception. The provided exception will be thrown by the service client.

        This will only be invoked if the entire execution fails. If a retriable error happens (according to the RetryPolicy) and a subsequent retry succeeds, this method will not be invoked.

        Parameters:
        context - The context associated with the execution that failed. An SDK request will always be available, but depending on the time at which the failure happened, the HTTP request, HTTP response and SDK response may not be available. This also includes the exception that triggered the failure.
        executionAttributes - A mutable set of attributes scoped to one specific request/response cycle that can be used to give data to future lifecycle methods.