Skip to content

Enable the fast unmarshalling codepath by default #6089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,8 @@ private MethodSpec finalizeServiceConfigurationMethod() {
.addCode(" .build());");

if (model.getMetadata().isJsonProtocol()) {
if (model.getCustomizationConfig().getEnableFastUnmarshaller()) {
builder.addStatement("builder.option($1T.ENABLE_FAST_UNMARSHALLER, true)",
SdkClientJsonProtocolAdvancedOption.class);
}
builder.addStatement("builder.option($1T.ENABLE_FAST_UNMARSHALLER, true)",
SdkClientJsonProtocolAdvancedOption.class);
}

if (hasRequestAlgorithmMember(model) || hasResponseAlgorithms(model)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.identity.spi.TokenIdentity;
import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption;
import software.amazon.awssdk.regions.ServiceMetadataAdvancedOption;
import software.amazon.awssdk.retries.api.RetryStrategy;
import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider;
Expand Down Expand Up @@ -59,13 +60,13 @@ protected final String serviceName() {
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)
.lazyOption(AwsClientOption.TOKEN_PROVIDER,
p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER)))
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()));
}

@Override
Expand All @@ -76,7 +77,7 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
endpointInterceptors.add(new JsonRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
.getInterceptors("software/amazon/awssdk/services/json/execution.interceptors");
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
Expand All @@ -92,21 +93,22 @@ protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientCon
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
builder.lazyOptionIfAbsent(
SdkClientOption.CLIENT_ENDPOINT_PROVIDER,
c -> AwsClientEndpointProvider
.builder()
.serviceEndpointOverrideEnvironmentVariable("AWS_ENDPOINT_URL_JSON_SERVICE")
.serviceEndpointOverrideSystemProperty("aws.endpointUrlJson")
.serviceProfileProperty("json_service")
.serviceEndpointPrefix(serviceEndpointPrefix())
.defaultProtocol("https")
.region(c.get(AwsClientOption.AWS_REGION))
.profileFile(c.get(SdkClientOption.PROFILE_FILE_SUPPLIER))
.profileName(c.get(SdkClientOption.PROFILE_NAME))
.putAdvancedOption(ServiceMetadataAdvancedOption.DEFAULT_S3_US_EAST_1_REGIONAL_ENDPOINT,
c.get(ServiceMetadataAdvancedOption.DEFAULT_S3_US_EAST_1_REGIONAL_ENDPOINT))
.dualstackEnabled(c.get(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED))
.fipsEnabled(c.get(AwsClientOption.FIPS_ENDPOINT_ENABLED)).build());
SdkClientOption.CLIENT_ENDPOINT_PROVIDER,
c -> AwsClientEndpointProvider
.builder()
.serviceEndpointOverrideEnvironmentVariable("AWS_ENDPOINT_URL_JSON_SERVICE")
.serviceEndpointOverrideSystemProperty("aws.endpointUrlJson")
.serviceProfileProperty("json_service")
.serviceEndpointPrefix(serviceEndpointPrefix())
.defaultProtocol("https")
.region(c.get(AwsClientOption.AWS_REGION))
.profileFile(c.get(SdkClientOption.PROFILE_FILE_SUPPLIER))
.profileName(c.get(SdkClientOption.PROFILE_NAME))
.putAdvancedOption(ServiceMetadataAdvancedOption.DEFAULT_S3_US_EAST_1_REGIONAL_ENDPOINT,
c.get(ServiceMetadataAdvancedOption.DEFAULT_S3_US_EAST_1_REGIONAL_ENDPOINT))
.dualstackEnabled(c.get(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED))
.fipsEnabled(c.get(AwsClientOption.FIPS_ENDPOINT_ENABLED)).build());
builder.option(SdkClientJsonProtocolAdvancedOption.ENABLE_FAST_UNMARSHALLER, true);
return builder.build();
}

Expand Down Expand Up @@ -194,6 +196,6 @@ private List<SdkPlugin> internalPlugins(SdkClientConfiguration config) {

protected static void validateClientOptions(SdkClientConfiguration c) {
Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER),
"The 'tokenProvider' must be configured in the client builder.");
"The 'tokenProvider' must be configured in the client builder.");
}
}
Loading
Loading