Skip to content

Commit a22917b

Browse files
committed
Fix HttpChecksumStage ordering and SIGNING_METHOD resolution for pipeline stage migration
1 parent a95bb32 commit a22917b

5 files changed

Lines changed: 25 additions & 2 deletions

File tree

core/aws-core/src/main/java/software/amazon/awssdk/awscore/internal/AwsExecutionContextBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import java.util.Optional;
2929
import software.amazon.awssdk.annotations.SdkInternalApi;
30+
import software.amazon.awssdk.auth.credentials.AwsCredentials;
3031
import software.amazon.awssdk.auth.signer.AwsSignerExecutionAttribute;
3132
import software.amazon.awssdk.awscore.AwsExecutionAttribute;
3233
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
@@ -184,6 +185,13 @@ private AwsExecutionContextBuilder() {
184185
signer, executionAttributes, executionAttributes.getOptionalAttribute(
185186
AwsSignerExecutionAttribute.AWS_CREDENTIALS).orElse(null)));
186187

188+
Signer resolvedSigner = signer;
189+
AwsCredentials capturedCredentials = executionAttributes.getOptionalAttribute(
190+
AwsSignerExecutionAttribute.AWS_CREDENTIALS).orElse(null);
191+
executionAttributes.putAttribute(SdkInternalExecutionAttribute.SIGNING_METHOD_UPDATER, attrs ->
192+
attrs.putAttribute(HttpChecksumConstant.SIGNING_METHOD,
193+
resolveSigningMethodUsed(resolvedSigner, attrs, capturedCredentials)));
194+
187195
putStreamingInputOutputTypesMetadata(executionAttributes, executionParams);
188196

189197
return ExecutionContext.builder()

core/sdk-core/src/main/java/software/amazon/awssdk/core/interceptor/SdkInternalExecutionAttribute.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121
import java.util.concurrent.atomic.AtomicLong;
22+
import java.util.function.Consumer;
2223
import software.amazon.awssdk.annotations.SdkProtectedApi;
2324
import software.amazon.awssdk.core.ClientEndpointProvider;
2425
import software.amazon.awssdk.core.SdkClient;
@@ -184,6 +185,13 @@ public final class SdkInternalExecutionAttribute extends SdkExecutionAttribute {
184185
public static final ExecutionAttribute<AuthSchemeOptionsResolver> AUTH_SCHEME_OPTIONS_RESOLVER =
185186
new ExecutionAttribute<>("AuthSchemeOptionsResolver");
186187

188+
/**
189+
* Callback to recompute {@code SIGNING_METHOD} after auth scheme resolution.
190+
* Set by {@code AwsExecutionContextBuilder}
191+
*/
192+
public static final ExecutionAttribute<Consumer<ExecutionAttributes>> SIGNING_METHOD_UPDATER =
193+
new ExecutionAttribute<>("SigningMethodUpdater");
194+
187195
/**
188196
* Callback for resolving the endpoint. Generated per-service as a lambda in the client class.
189197
* Called by EndpointResolutionStage after interceptors have run.

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/AmazonAsyncHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ public <OutputT> CompletableFuture<OutputT> execute(
199199
.then(MergeCustomQueryParamsStage::new)
200200
.then(QueryParametersToBodyStage::new)
201201
.then(() -> new CompressRequestStage(httpClientDependencies))
202-
.then(() -> new HttpChecksumStage(ClientType.ASYNC))
203202
.then(AuthSchemeResolutionStage::new)
204203
.then(EndpointResolutionStage::new)
204+
.then(() -> new HttpChecksumStage(ClientType.ASYNC))
205205
.then(ApplyUserAgentStage::new)
206206
.then(MakeRequestImmutableStage::new)
207207
.then(RequestPipelineBuilder

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/AmazonSyncHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ public <OutputT> OutputT execute(HttpResponseHandler<Response<OutputT>> response
187187
.then(MergeCustomQueryParamsStage::new)
188188
.then(QueryParametersToBodyStage::new)
189189
.then(() -> new CompressRequestStage(httpClientDependencies))
190-
.then(() -> new HttpChecksumStage(ClientType.SYNC))
191190
.then(AuthSchemeResolutionStage::new)
192191
.then(EndpointResolutionStage::new)
192+
.then(() -> new HttpChecksumStage(ClientType.SYNC))
193193
.then(ApplyUserAgentStage::new)
194194
.then(MakeRequestImmutableStage::new)
195195
// End of mutating request

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AuthSchemeResolutionStage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.List;
1919
import java.util.Map;
20+
import java.util.function.Consumer;
2021
import software.amazon.awssdk.annotations.SdkInternalApi;
2122
import software.amazon.awssdk.core.RequestOverrideConfiguration;
2223
import software.amazon.awssdk.core.SdkRequest;
@@ -80,6 +81,12 @@ public SdkHttpFullRequest.Builder execute(SdkHttpFullRequest.Builder request, Re
8081

8182
executionAttributes.putAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME, selectedAuthScheme);
8283

84+
Consumer<ExecutionAttributes> signingMethodUpdater =
85+
executionAttributes.getAttribute(SdkInternalExecutionAttribute.SIGNING_METHOD_UPDATER);
86+
if (signingMethodUpdater != null) {
87+
signingMethodUpdater.accept(executionAttributes);
88+
}
89+
8390
recordBusinessMetrics(selectedAuthScheme, sdkRequest, executionAttributes);
8491

8592
return request;

0 commit comments

Comments
 (0)