AmazonWebServicesClientProxy.logRequestMetadataV2 causes a premature evaluation of the response object
まだ誰も着手していません。
評価
調査の方向性
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 はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws-cloudformation/cloudformation-cli-java-plugin のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
aws-cloudformation/cloudformation-cli-java-plugin#415 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
-
injectCredentialsAndInvokeV2 method in proxy class doesn't support API's like PutObject from S3.オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
aws-cloudformation/cloudformation-cli-java-plugin の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
SAP/ai-sdk-java#1206 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue insight-module
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
sdlc-pro/spring-lens#606 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/cloudstack#14719 ·
メンテナーはふだん 1 日以内に返信
-
quality-assurance
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#252 ·
メンテナーはふだん 1 日以内に返信
-
backlog kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
TencentBlueKing/bk-job#4627 ·
メンテナーはふだん 1 日以内に返信