AmazonWebServicesClientProxy.logRequestMetadataV2 causes a premature evaluation of the response object
还没有人认领这个 Issue。
评估
调研方向
从 injectCredentialsAndInvokeV2Async、injectCredentialsAndInvokeIterableV2、injectCredentialsAndInvokeV2InputStream 和 injectCredentialsAndInvokeV2Bytes 开始,然后检查每个方法如何调用 logRequestMetadataV2。验证 lazy 的 CompletableFuture、SdkIterable 和 ResponseInputStream 结果不会在日志记录期间被消费,同时确保已立即解析的响应仍会记录元数据,且不会导致重复的服务 API 调用。
由索引模型根据 Issue 内容生成。
描述
Summary: AmazonWebServicesClientProxy.logRequestMetadataV2 causes lazily-evaluated SDK response objects (streams, iterables) to be evaluated immediately. A response resolve would immediately engage the SDK client and execute the service API calls. Whenever a consumer of this response object would access the data again, it would have to be re-resolved and the same API calls would be executed once again. The issue issue exists in the latest lib version.
Example: using injectCredentialsAndInvokeIterableV2 paginated operation causes the SDK to perform 2x more API requests.
Details:
AmazonWebServicesClientProxy exposes multiple handles to interact with the SDK client. A response object could be either immediately (plain AwsResponse object) or lazily (CompletableFuture<ResponseT>, SdkIterable<ResponseT>, ResponseInputStream<ResponseT>) evaluated. A private logging routine called logRequestMetadataV2 causes lazily evaluated response objects to be evaluated immediately for the sake of logging. The resolve would cause a full range of the service API calls to be executed. By default, the SDK would not perform a deep response cache, hence a secondary access to the response data would once again hook up the SDK client, which would perform the same set of API calls.
public <RequestT extends AwsRequest, ResultT extends AwsResponse, IterableT extends SdkIterable<ResultT>>
IterableT
injectCredentialsAndInvokeIterableV2(final RequestT request, final Function<RequestT, IterableT> requestFunction) {
AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder()
.credentialsProvider(v2CredentialsProvider).build();
@SuppressWarnings("unchecked")
RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
try {
IterableT response = requestFunction.apply(wrappedRequest);
response.forEach(r -> logRequestMetadataV2(request, r)); // <- this invocation would resolve the response object immediately
return response; // <- the response object is returned to the invoker. It would be re-resolved upon a data access.
} catch (final Throwable e) {
loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage()));
throw e;
}
}
Possible Mitigation: logRequestMetadataV2 (and any other kind of non-lazy logging) should be avoided on all non-immediately resolved result types in the following routines:
injectCredentialsAndInvokeV2AsyncinjectCredentialsAndInvokeIterableV2injectCredentialsAndInvokeV2InputStreaminjectCredentialsAndInvokeV2Bytes
- 主要语言
- Java
- 星标
- 30
- 派生
- 48
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws-cloudformation/cloudformation-cli-java-plugin 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 25/100
aws-cloudformation/cloudformation-cli-java-plugin#415 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 20/100
-
injectCredentialsAndInvokeV2 method in proxy class doesn't support API's like PutObject from S3. 未关闭
难度 5/5 一周以上 新手友好度 25/100
-
难度 2/5 1-3 小时 新手友好度 35/100
查看 aws-cloudformation/cloudformation-cli-java-plugin 的全部 Issue
相似的 Issue
-
area/plugin
难度 2/5 1-3 小时 新手友好度 75/100
kestra-io/plugin-kestra#190 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
apache/rocketmq-dashboard#5064 ·