Skip to content

Commit e5b53e1

Browse files
Nicholas DeJacodagnir
authored andcommitted
Fix streaming requests test failure
1 parent 89930fa commit e5b53e1

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected RequestOverrideConfiguration(Builder<?> builder) {
5959
this.apiCallAttemptTimeout = Validate.isPositiveOrNull(builder.apiCallAttemptTimeout(), "apiCallAttemptTimeout");
6060
this.signer = builder.signer();
6161
this.metricPublishers = Collections.unmodifiableList(new ArrayList<>(builder.metricPublishers()));
62-
this.executionAttributes = new UnmodifiableExecutionAttributes(builder.executionAttributes().build());
62+
this.executionAttributes = new UnmodifiableExecutionAttributes(builder.executionAttributes());
6363
}
6464

6565
/**
@@ -402,7 +402,7 @@ default B putRawQueryParameter(String name, String value) {
402402
*/
403403
<T> B putExecutionAttribute(ExecutionAttribute<T> attribute, T value);
404404

405-
ExecutionAttributes.Builder executionAttributes();
405+
ExecutionAttributes executionAttributes();
406406

407407
/**
408408
* Create a new {@code SdkRequestOverrideConfiguration} with the properties set on this builder.
@@ -575,8 +575,8 @@ public <T> B putExecutionAttribute(ExecutionAttribute<T> executionAttribute, T v
575575
}
576576

577577
@Override
578-
public ExecutionAttributes.Builder executionAttributes() {
579-
return executionAttributes;
578+
public ExecutionAttributes executionAttributes() {
579+
return executionAttributes.build();
580580
}
581581

582582
public void setExecutionAttributes(Map<ExecutionAttribute<?>, Object> executionAttributes) {

core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/ClientOverrideConfiguration.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private ClientOverrideConfiguration(Builder builder) {
7575
this.defaultProfileFile = builder.defaultProfileFile();
7676
this.defaultProfileName = builder.defaultProfileName();
7777
this.metricPublishers = Collections.unmodifiableList(new ArrayList<>(builder.metricPublishers()));
78-
this.executionAttributes = new UnmodifiableExecutionAttributes(builder.executionAttributes().build());
78+
this.executionAttributes = new UnmodifiableExecutionAttributes(builder.executionAttributes());
7979
}
8080

8181
@Override
@@ -87,7 +87,8 @@ public Builder toBuilder() {
8787
.apiCallAttemptTimeout(apiCallAttemptTimeout)
8888
.executionInterceptors(executionInterceptors)
8989
.defaultProfileFile(defaultProfileFile)
90-
.defaultProfileName(defaultProfileName);
90+
.defaultProfileName(defaultProfileName)
91+
.executionAttributes(executionAttributes.getAttributes());
9192
}
9293

9394
/**
@@ -468,7 +469,7 @@ default Builder retryPolicy(RetryMode retryMode) {
468469
*/
469470
<T> Builder putExecutionAttribute(ExecutionAttribute<T> attribute, T value);
470471

471-
ExecutionAttributes.Builder executionAttributes();
472+
ExecutionAttributes executionAttributes();
472473
}
473474

474475
/**
@@ -663,8 +664,8 @@ public <T> Builder putExecutionAttribute(ExecutionAttribute<T> executionAttribut
663664
}
664665

665666
@Override
666-
public ExecutionAttributes.Builder executionAttributes() {
667-
return executionAttributes;
667+
public ExecutionAttributes executionAttributes() {
668+
return executionAttributes.build();
668669
}
669670

670671
@Override

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/handler/BaseAsyncClientHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ public <InputT extends SdkRequest, OutputT extends SdkResponse, ReturnT> Complet
113113
AsyncStreamingResponseHandler<OutputT, ReturnT> asyncStreamingResponseHandler =
114114
new AsyncStreamingResponseHandler<>(asyncResponseTransformer);
115115

116+
ExecutionContext context = createExecutionContext(executionParams, executionAttributes);
117+
116118
// For streaming requests, prepare() should be called as early as possible to avoid NPE in client
117119
// See https://github.com/aws/aws-sdk-java-v2/issues/1268. We do this with a wrapper that caches the prepare
118120
// result until the execution attempt number changes. This guarantees that prepare is only called once per
119121
// execution.
120122
TransformingAsyncResponseHandler<ReturnT> wrappedAsyncStreamingResponseHandler =
121123
IdempotentAsyncResponseHandler.create(
122124
asyncStreamingResponseHandler,
123-
() -> executionAttributes.getAttribute(InternalCoreExecutionAttribute.EXECUTION_ATTEMPT),
125+
() -> context.executionAttributes().getAttribute(InternalCoreExecutionAttribute.EXECUTION_ATTEMPT),
124126
Integer::equals);
125127
wrappedAsyncStreamingResponseHandler.prepare();
126128

127-
ExecutionContext context = createExecutionContext(executionParams, executionAttributes);
128-
129129
HttpResponseHandler<OutputT> decoratedResponseHandlers =
130130
decorateResponseHandlers(executionParams.getResponseHandler(), context);
131131

0 commit comments

Comments
 (0)