Skip to content

Commit 07b72ee

Browse files
committed
Address review comments
1 parent 788b1f0 commit 07b72ee

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

protocols/aws-xml-protocol/src/main/java/software/amazon/awssdk/protocols/xml/internal/AwsXmlProtocolFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ public AwsXmlProtocolFactory build() {
8585
return new AwsXmlProtocolFactory(this);
8686
}
8787
}
88-
}
88+
}

protocols/aws-xml-protocol/src/main/java/software/amazon/awssdk/protocols/xml/internal/marshall/XmlPayloadMarshaller.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@ public class XmlPayloadMarshaller {
5151
public static final XmlMarshaller<Instant> INSTANT =
5252
new BasePayloadMarshaller<>(XmlProtocolMarshaller.INSTANT_VALUE_TO_STRING);
5353

54-
public static final XmlMarshaller<SdkBytes> SDK_BYTES = new BasePayloadMarshaller<SdkBytes>(null) {
55-
@Override
56-
public void marshall(SdkBytes val, XmlMarshallerContext context, String paramName, SdkField<SdkBytes> sdkField,
57-
ValueToStringConverter.ValueToString<SdkBytes> converter) {
58-
context.xmlGenerator().xmlWriter().value(val.asByteBuffer());
59-
}
60-
};
54+
public static final XmlMarshaller<SdkBytes> SDK_BYTES = new BasePayloadMarshaller<>(ValueToStringConverter.FROM_SDK_BYTES);
6155

6256
public static final XmlMarshaller<SdkPojo> SDK_POJO = new BasePayloadMarshaller<SdkPojo>(null) {
6357
@Override

services/s3/src/main/java/software/amazon/awssdk/services/s3/handlers/AddContentMd5HeaderInterceptor.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,32 @@
2020
import java.io.ByteArrayOutputStream;
2121
import java.io.IOException;
2222
import java.io.UncheckedIOException;
23+
import java.util.Arrays;
24+
import java.util.List;
2325
import software.amazon.awssdk.annotations.SdkProtectedApi;
2426
import software.amazon.awssdk.core.interceptor.Context;
2527
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
2628
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
2729
import software.amazon.awssdk.http.SdkHttpFullRequest;
30+
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
31+
import software.amazon.awssdk.services.s3.model.UploadPartRequest;
2832
import software.amazon.awssdk.utils.IoUtils;
2933
import software.amazon.awssdk.utils.Md5Utils;
3034

3135
@SdkProtectedApi
3236
public class AddContentMd5HeaderInterceptor implements ExecutionInterceptor {
3337

38+
// List of operations that should be ignored by this interceptor.
39+
// These are costly operations, so adding the md5 header will take a performance hit
40+
private static final List<Class> BLACKLIST_METHODS = Arrays.asList(PutObjectRequest.class, UploadPartRequest.class);
41+
3442
@Override
3543
public SdkHttpFullRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
3644
SdkHttpFullRequest request = context.httpRequest();
37-
if (request.contentStreamProvider().isPresent() && !request.firstMatchingHeader(CONTENT_MD5).isPresent()) {
45+
46+
if (!BLACKLIST_METHODS.contains(context.request().getClass()) && request.contentStreamProvider().isPresent()
47+
&& !request.firstMatchingHeader(CONTENT_MD5).isPresent()) {
48+
3849
try {
3950
ByteArrayOutputStream baos = new ByteArrayOutputStream();
4051
IoUtils.copy(request.contentStreamProvider().get().newStream(), baos);

0 commit comments

Comments
 (0)