Skip to content

Commit d5aa0e9

Browse files
committed
Handle autoconstruct lists in non-JSON protocols
1 parent 28bd992 commit d5aa0e9

File tree

8 files changed

+33
-20
lines changed

8 files changed

+33
-20
lines changed

codegen/src/main/resources/macros/marshaller/ec2/MemberMarshallerMacro.ftl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
<#local loopVariable = listVariable + "Value"/>
3232

3333
${listModel.templateType} ${listVariable} = ${getMember}();
34-
if (${listVariable} != null) {
34+
<#if customConfig.useAutoConstructList>
35+
if (!${listVariable}.isEmpty() || !(${listVariable} instanceof software.amazon.awssdk.core.util.SdkAutoConstructList)) {
36+
<#else>
37+
if (${listVariable} != null) {
38+
</#if>
3539
int ${listIndex} = 1;
3640

3741
for (${listModel.memberType} ${loopVariable} : ${listVariable}) {

codegen/src/main/resources/macros/marshaller/query/MemberMarshallerMacro.ftl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@
5656
</#if>
5757
</#if>
5858

59-
${listModel.templateType} ${listVariable} = ${getMember}();
60-
61-
if (${listVariable} != null) {
62-
if (!${listVariable}.isEmpty()) {
59+
<#if customConfig.useAutoConstructList>
60+
if (${getMember}().isEmpty() && !(${getMember}() instanceof software.amazon.awssdk.core.util.SdkAutoConstructList)) {
61+
request.addParameter("${parameterRootPath}", "");
62+
} else if (!${getMember}().isEmpty() && !(${getMember}() instanceof software.amazon.awssdk.core.util.SdkAutoConstructList)) {
63+
${listModel.templateType} ${listVariable} = ${getMember}();
64+
<#else>
65+
if (${getMember}() != null) {
66+
${listModel.templateType} ${listVariable} = ${getMember}();
67+
if (${listVariable}.isEmpty()) {
68+
request.addParameter("${parameterRootPath}", "");
69+
} else {
70+
</#if>
6371
int ${listIndex} = 1;
6472

6573
for (${listModel.memberType} ${loopVariable} : ${listVariable}) {
@@ -72,9 +80,9 @@
7280
</#if>
7381
${listIndex}++;
7482
}
75-
} else {
76-
request.addParameter("${parameterRootPath}", "");
83+
<#if !customConfig.useAutoConstructList>
7784
}
85+
</#if>
7886
}
7987
<#elseif member.map>
8088
<#local parameterPath = http.marshallLocationName/>

codegen/src/main/resources/macros/marshaller/rest-xml/MemberMarshallerMacro.ftl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
<#local listVariable = shapeName?uncap_first + member.name + "List"/>
2222
<#local loopVariable = listVariable + "Value"/>
2323

24-
${listModel.templateType} ${listVariable} = ${getMember}();
25-
if (${listVariable} != null) {
24+
${listModel.templateType} ${listVariable} = ${getMember}();
25+
<#if customConfig.useAutoConstructList>
26+
if (!${listVariable}.isEmpty() || !(${listVariable} instanceof software.amazon.awssdk.core.util.SdkAutoConstructList)) {
27+
<#else>
28+
if (${listVariable} != null) {
29+
</#if>
2630
<#if member.http.flattened>
2731
for (${listModel.memberType} ${loopVariable} : ${listVariable}) {
2832
<#local memberLocationName = listModel.memberLocationName!http.marshallLocationName />

services/rds/src/test/java/software/amazon/awssdk/services/rds/PresignRequestHandlerTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,13 @@ public void testComputesPresignedUrlCorrectly() throws URISyntaxException {
9797
"&SourceDBSnapshotIdentifier=arn%3Aaws%3Ards%3Aus-east-1%3A123456789012%3Asnapshot%3Ards%3Atest-instance-ss-2016-12-20-23-19" +
9898
"&TargetDBSnapshotIdentifier=test-instance-ss-copy-2" +
9999
"&KmsKeyId=arn%3Aaws%3Akms%3Aus-west-2%3A123456789012%3Akey%2F11111111-2222-3333-4444-555555555555" +
100-
// FIXME: The empty "Tags" list should not be getting
101-
// marshalled, but we need to fix the marshallers to be aware
102-
// of auto construct lists
103-
"&Tags=" +
104100
"&DestinationRegion=us-west-2" +
105101
"&X-Amz-Algorithm=AWS4-HMAC-SHA256" +
106102
"&X-Amz-Date=20161221T180735Z" +
107103
"&X-Amz-SignedHeaders=host" +
108104
"&X-Amz-Expires=604800" +
109105
"&X-Amz-Credential=foo%2F20161221%2Fus-east-1%2Frds%2Faws4_request" +
110-
"&X-Amz-Signature=6a7e40b24c91517a6de0e60bc65a1a812deaa0a0aa3b54ab513bef3ed34f78c9";
106+
"&X-Amz-Signature=f839ca3c728dc96e7c978befeac648296b9f778f6724073de4217173859d13d9";
111107

112108
assertEquals(expectedPreSignedUrl, presignedRequest.rawQueryParameters().get("PreSignedUrl").get(0));
113109
}

services/s3/src/it/java/software/amazon/awssdk/services/s3/BucketAnalyticsConfigurationIntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.assertFalse;
2020
import static org.junit.Assert.assertNotNull;
2121
import static org.junit.Assert.assertNull;
22+
import static org.junit.Assert.assertTrue;
2223
import static software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName;
2324

2425
import java.util.List;
@@ -144,7 +145,7 @@ public void testDeleteBucketAnalyticsConfiguration() throws Exception {
144145
s3.listBucketAnalyticsConfigurations(ListBucketAnalyticsConfigurationsRequest.builder()
145146
.bucket(BUCKET_NAME)
146147
.build());
147-
assertNull(result.analyticsConfigurationList());
148+
assertTrue(result.analyticsConfigurationList().isEmpty());
148149
}
149150

150151
@Test

services/s3/src/it/java/software/amazon/awssdk/services/s3/BucketInventoryConfigurationIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void testInventoryConfiguration_works_properly_with_setting_only_required
125125
.bucket(BUCKET_NAME)
126126
.build())
127127
.inventoryConfigurationList();
128-
assertNull(configurations);
128+
assertTrue(configurations.isEmpty());
129129
}
130130

131131
@Test

test/protocol-tests/src/main/resources/codegen-resources/query/customization.config

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010
"queryParamWithoutValue",
1111
"idempotentOperation",
1212
"queryTypes"
13-
]
13+
],
14+
// The tests expect non auto construct lists
15+
"useAutoConstructList": false
1416
}

test/protocol-tests/src/main/resources/codegen-resources/restxml/customization.config

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
"operationWithModeledContentType",
1010
"queryParamWithoutValue",
1111
"restXmlTypes"
12-
],
13-
// FIXME: RestXml marshallers need to be made auto construct aware
14-
"useAutoConstructList": false
12+
]
1513
}

0 commit comments

Comments
 (0)