Skip to content

Commit

Permalink
fix(client-s3): disable bucket endpoint plugin in WriteGetObjectRespo…
Browse files Browse the repository at this point in the history
…nseCommand (#3344)

* fix(client-s3): disable bucket endpoint pluggin for WriteGetObjectResponseCommand

* chore: fix checkstyle error

Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
  • Loading branch information
AllanZhengYP and trivikr committed Feb 23, 2022
1 parent bfc9257 commit 1945d47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
@@ -1,4 +1,3 @@
import { getBucketEndpointPlugin } from "@aws-sdk/middleware-bucket-endpoint";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
Expand Down Expand Up @@ -93,7 +92,6 @@ export class WriteGetObjectResponseCommand extends $Command<
options?: __HttpHandlerOptions
): Handler<WriteGetObjectResponseCommandInput, WriteGetObjectResponseCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(getBucketEndpointPlugin(configuration));

const stack = clientStack.concat(this.middlewareStack);

Expand Down
Expand Up @@ -55,7 +55,9 @@
public final class AddS3Config implements TypeScriptIntegration {
private static final Logger LOGGER = Logger.getLogger(AddS3Config.class.getName());

private static final Set<String> SSEC_OPERATIONS = SetUtils.of("SSECustomerKey", "CopySourceSSECustomerKey");
private static final Set<String> SSEC_INPUT_KEYS = SetUtils.of("SSECustomerKey", "CopySourceSSECustomerKey");

private static final Set<String> BUCKET_ENDPOINT_INPUT_KEYS = SetUtils.of("Bucket");

private static final Set<String> NON_BUCKET_ENDPOINT_OPERATIONS = SetUtils.of(
"CreateBucket",
Expand Down Expand Up @@ -178,14 +180,14 @@ && testServiceId(s))
.build(),
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.SSEC_MIDDLEWARE.dependency, "Ssec", HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, SSEC_OPERATIONS)
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, SSEC_INPUT_KEYS)
&& testServiceId(s))
.build(),
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.LOCATION_CONSTRAINT.dependency, "LocationConstraint",
HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("CreateBucket")
&& testServiceId(s))
&& testServiceId(s))
.build(),
/**
* BUCKET_ENDPOINT_MIDDLEWARE needs two separate plugins. The first resolves the config in the client.
Expand All @@ -200,7 +202,8 @@ && testServiceId(s))
.withConventions(AwsDependency.BUCKET_ENDPOINT_MIDDLEWARE.dependency, "BucketEndpoint",
HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> !NON_BUCKET_ENDPOINT_OPERATIONS.contains(o.getId().getName(s))
&& testServiceId(s))
&& testServiceId(s)
&& testInputContainsMember(m, o, BUCKET_ENDPOINT_INPUT_KEYS))
.build()
);
}
Expand Down

0 comments on commit 1945d47

Please sign in to comment.