Skip to content

Commit 1450398

Browse files
authored
Move SDK-provided global execution.interceptors a hard-coded list. (aws#2734)
This reduces the need for customers to use a special transformer for execution.interceptors files when they are creating an uber-jar of all SDK modules. Customers should still consider using such an appender, in case other libraries rely on execution.interceptors files.
1 parent 5f145e8 commit 1450398

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"contributor": "",
4+
"type": "feature",
5+
"description": "Remove SDK usage of global execution.interceptors files. This reduces the need for customers to use a special transformer for execution.interceptors files when they are creating an uber-jar of all SDK modules. Customers should still consider using such an appender, in case other libraries rely on execution.interceptors files."
6+
}

core/aws-core/src/main/java/software/amazon/awssdk/awscore/client/builder/AwsDefaultClientBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package software.amazon.awssdk.awscore.client.builder;
1717

1818
import java.net.URI;
19-
import java.util.Collections;
19+
import java.util.Arrays;
2020
import java.util.List;
2121
import java.util.Optional;
2222
import software.amazon.awssdk.annotations.SdkProtectedApi;
@@ -26,6 +26,7 @@
2626
import software.amazon.awssdk.awscore.client.config.AwsAdvancedClientOption;
2727
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
2828
import software.amazon.awssdk.awscore.endpoint.DefaultServiceEndpointBuilder;
29+
import software.amazon.awssdk.awscore.eventstream.EventStreamInitialRequestInterceptor;
2930
import software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor;
3031
import software.amazon.awssdk.awscore.retry.AwsRetryPolicy;
3132
import software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder;
@@ -267,6 +268,7 @@ private List<ExecutionInterceptor> addAwsInterceptors(SdkClientConfiguration con
267268
}
268269

269270
private List<ExecutionInterceptor> awsInterceptors() {
270-
return Collections.singletonList(new HelpfulUnknownHostExceptionInterceptor());
271+
return Arrays.asList(new HelpfulUnknownHostExceptionInterceptor(),
272+
new EventStreamInitialRequestInterceptor());
271273
}
272274
}

core/aws-core/src/main/resources/software/amazon/awssdk/global/handlers/execution.interceptors

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import java.net.URI;
4444
import java.util.ArrayList;
45+
import java.util.Collections;
4546
import java.util.LinkedHashMap;
4647
import java.util.List;
4748
import java.util.Optional;
@@ -63,6 +64,7 @@
6364
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
6465
import software.amazon.awssdk.core.internal.http.loader.DefaultSdkAsyncHttpClientBuilder;
6566
import software.amazon.awssdk.core.internal.http.loader.DefaultSdkHttpClientBuilder;
67+
import software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor;
6668
import software.amazon.awssdk.core.retry.RetryMode;
6769
import software.amazon.awssdk.core.retry.RetryPolicy;
6870
import software.amazon.awssdk.core.util.SdkUserAgent;
@@ -334,10 +336,20 @@ private ScheduledExecutorService resolveScheduledExecutorService() {
334336
* Finalize which execution interceptors will be used for the created client.
335337
*/
336338
private List<ExecutionInterceptor> resolveExecutionInterceptors(SdkClientConfiguration config) {
337-
List<ExecutionInterceptor> globalInterceptors = new ClasspathInterceptorChainFactory().getGlobalInterceptors();
339+
List<ExecutionInterceptor> globalInterceptors = new ArrayList<>();
340+
globalInterceptors.addAll(sdkInterceptors());
341+
globalInterceptors.addAll(new ClasspathInterceptorChainFactory().getGlobalInterceptors());
338342
return mergeLists(globalInterceptors, config.option(EXECUTION_INTERCEPTORS));
339343
}
340344

345+
346+
/**
347+
* The set of interceptors that should be included with all services.
348+
*/
349+
private List<ExecutionInterceptor> sdkInterceptors() {
350+
return Collections.singletonList(new HttpChecksumRequiredInterceptor());
351+
}
352+
341353
@Override
342354
public final B endpointOverride(URI endpointOverride) {
343355
Validate.paramNotNull(endpointOverride, "endpointOverride");

core/sdk-core/src/main/resources/software/amazon/awssdk/global/handlers/execution.interceptors

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)