-
Notifications
You must be signed in to change notification settings - Fork 872
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
Move QueryParametersToBodyInterceptor to front of interceptor chain #4109
Merged
davidh44
merged 6 commits into
master
from
hdavidh/move-queryParametersToBodyInterceptors-to-front-of-interceptor-chain
Jun 21, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
57d7f59
Move QueryParametersToBodyInterceptor to front of interceptor chain
davidh44 f31c32e
Move customization.config interceptors to front of interceptor chain …
davidh44 5e5a458
Refactoring
davidh44 67f47d5
Add codegen tests
davidh44 8f7f99d
Refactoring
davidh44 a37f419
Refactoring
davidh44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...test/java/software/amazon/awssdk/codegen/internal/QueryProtocolCustomTestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package software.amazon.awssdk.codegen.internal; | ||
|
||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.codegen.poet.builder.BuilderClassTest; | ||
|
||
/** | ||
* Empty no-op test interceptor for query protocols to view generated code in test-query-sync-client-builder-class.java and | ||
* test-query-async-client-builder-class.java and validate in {@link BuilderClassTest}. | ||
*/ | ||
@SdkInternalApi | ||
public class QueryProtocolCustomTestInterceptor { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...es/software/amazon/awssdk/codegen/poet/builder/test-query-async-client-builder-class.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package software.amazon.awssdk.services.query; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import software.amazon.awssdk.annotations.Generated; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; | ||
import software.amazon.awssdk.awscore.client.config.AwsClientOption; | ||
import software.amazon.awssdk.codegen.internal.QueryProtocolCustomTestInterceptor; | ||
import software.amazon.awssdk.core.client.config.SdkClientConfiguration; | ||
import software.amazon.awssdk.core.client.config.SdkClientOption; | ||
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; | ||
import software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor; | ||
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; | ||
import software.amazon.awssdk.utils.CollectionUtils; | ||
|
||
/** | ||
* Internal implementation of {@link QueryAsyncClientBuilder}. | ||
*/ | ||
@Generated("software.amazon.awssdk:codegen") | ||
@SdkInternalApi | ||
final class DefaultQueryAsyncClientBuilder extends DefaultQueryBaseClientBuilder<QueryAsyncClientBuilder, QueryAsyncClient> | ||
implements QueryAsyncClientBuilder { | ||
@Override | ||
public DefaultQueryAsyncClientBuilder endpointProvider(QueryEndpointProvider endpointProvider) { | ||
clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); | ||
return this; | ||
} | ||
|
||
@Override | ||
public DefaultQueryAsyncClientBuilder tokenProvider(SdkTokenProvider tokenProvider) { | ||
clientConfiguration.option(AwsClientOption.TOKEN_PROVIDER, tokenProvider); | ||
return this; | ||
} | ||
|
||
@Override | ||
protected final QueryAsyncClient buildClient() { | ||
SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration(); | ||
List<ExecutionInterceptor> interceptors = clientConfiguration.option(SdkClientOption.EXECUTION_INTERCEPTORS); | ||
List<ExecutionInterceptor> queryParamsToBodyInterceptor = Collections | ||
.singletonList(new QueryParametersToBodyInterceptor()); | ||
List<ExecutionInterceptor> customizationInterceptors = new ArrayList<>(); | ||
customizationInterceptors.add(new QueryProtocolCustomTestInterceptor()); | ||
interceptors = CollectionUtils.mergeLists(queryParamsToBodyInterceptor, interceptors); | ||
interceptors = CollectionUtils.mergeLists(customizationInterceptors, interceptors); | ||
clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors) | ||
.build(); | ||
this.validateClientOptions(clientConfiguration); | ||
URI endpointOverride = null; | ||
if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null | ||
&& Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) { | ||
endpointOverride = clientConfiguration.option(SdkClientOption.ENDPOINT); | ||
} | ||
QueryServiceClientConfiguration serviceClientConfiguration = QueryServiceClientConfiguration.builder() | ||
.overrideConfiguration(overrideConfiguration()).region(clientConfiguration.option(AwsClientOption.AWS_REGION)) | ||
.endpointOverride(endpointOverride).build(); | ||
return new DefaultQueryAsyncClient(serviceClientConfiguration, clientConfiguration); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand the need for the other changes. Any reason we can't just change the ordering of this statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this
finalizeServiceConfiguration()
the service-specific interceptors are added to theSdkClientConfiguration
asSdkClientOption.EXECUTION_INTERCEPTORS
which are then merged with the global interceptors in SdkDefaultClientBuilder. So changing the ordering here would only move the interceptor to the front of the service-specific interceptors; it would still come after the global interceptors.Alternatively, we could create another SdkClientOption here and merge it in SdkDefaultClientBuilder, but to keep cross-module dependencies down Matt proposed we add it in the
SyncClientBuilderClass
/AsyncClientBuilderClass