Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnir committed Dec 1, 2022
1 parent 94ed385 commit 966f995
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ private MethodSpec modifyRequestMethod() {
b.beginControlFlow("try");
b.addStatement("$T result = $N.resolveEndpoint(ruleParams(context, executionAttributes)).join()", Endpoint.class,
providerVar);
b.beginControlFlow("if (!$T.disableHostPrefixInjection(executionAttributes))",
endpointRulesSpecUtils.rulesRuntimeClassName("AwsEndpointProviderUtils"));
b.addStatement("$T hostPrefix = hostPrefix(executionAttributes.getAttribute($T.OPERATION_NAME), context.request())",
ParameterizedTypeName.get(Optional.class, String.class), SdkExecutionAttribute.class);
b.beginControlFlow("if (hostPrefix.isPresent() && !$T.disableHostPrefixInjection(executionAttributes))",
endpointRulesSpecUtils.rulesRuntimeClassName("AwsEndpointProviderUtils"));
b.beginControlFlow("if (hostPrefix.isPresent())");
b.addStatement("result = $T.addHostPrefix(result, hostPrefix.get())",
endpointRulesSpecUtils.rulesRuntimeClassName("AwsEndpointProviderUtils"));
b.endControlFlow();
b.endControlFlow();
b.addStatement("executionAttributes.putAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT, result)");
b.addStatement("return context.request()");
b.endControlFlow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public SdkRequest modifyRequest(Context.ModifyRequest context, ExecutionAttribut
.getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER);
try {
Endpoint result = provider.resolveEndpoint(ruleParams(context, executionAttributes)).join();
Optional<String> hostPrefix = hostPrefix(executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME),
context.request());
if (hostPrefix.isPresent() && !AwsEndpointProviderUtils.disableHostPrefixInjection(executionAttributes)) {
result = AwsEndpointProviderUtils.addHostPrefix(result, hostPrefix.get());
if (!AwsEndpointProviderUtils.disableHostPrefixInjection(executionAttributes)) {
Optional<String> hostPrefix = hostPrefix(executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME),
context.request());
if (hostPrefix.isPresent()) {
result = AwsEndpointProviderUtils.addHostPrefix(result, hostPrefix.get());
}
}
executionAttributes.putAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT, result);
return context.request();
Expand Down

0 comments on commit 966f995

Please sign in to comment.