Skip to content

Commit ebf23e9

Browse files
committed
Build fixes and integ test fixes
1 parent 27e7fc6 commit ebf23e9

File tree

8 files changed

+50
-12
lines changed

8 files changed

+50
-12
lines changed

buildspecs/on-demand-integ-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 0.2
2+
3+
phases:
4+
build:
5+
commands:
6+
- mvn clean verify -Dskip.unit.tests -P integration-tests -Dfindbugs.skip -Dcheckstyle.skip -pl !:dynamodbmapper-v1 -Dfailsafe.rerunFailingTestsCount=1 -Dmaven.wagon.httpconnectionManager.maxPerRoute=2 --fail-at-end

codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,13 @@ private String findRequestUri(Shape parentShape, Map<String, Shape> allC2jShapes
271271
}
272272

273273
private String deriveUnmarshallerLocationName(Shape memberShape, String memberName, Member member) {
274-
String locationName = memberShape.getListMember() != null && memberShape.isFlattened() ?
275-
memberShape.getListMember().getLocationName() : member.getLocationName();
274+
String locationName;
275+
if (memberShape.getListMember() != null && memberShape.isFlattened()) {
276+
locationName = memberShape.getListMember().getLocationName() == null ?
277+
member.getLocationName() : memberShape.getListMember().getLocationName();
278+
} else {
279+
locationName = member.getLocationName();
280+
}
276281

277282
if (locationName != null && !locationName.trim().isEmpty()) {
278283
return locationName;

protocols/aws-json/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public <T extends software.amazon.awssdk.awscore.AwsRequest> ProtocolMarshaller<
152152
/**
153153
* Builder for {@link AwsJsonProtocolFactory}.
154154
*/
155-
public static abstract class Builder<SubclassT extends Builder> {
155+
public abstract static class Builder<SubclassT extends Builder> {
156156

157157
private final JsonClientMetadata metadata = new JsonClientMetadata();
158158
private final AwsJsonProtocolMetadata.Builder protocolMetadata = AwsJsonProtocolMetadata.builder();

protocols/aws-query/src/main/java/software/amazon/awssdk/protocols/query/internal/marshall/SimpleTypeQueryMarshaller.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ public void marshall(QueryMarshallerContext context, String path, T val, SdkFiel
7272
/**
7373
* @return Default timestamp formats for each location supported by the Query protocol.
7474
*/
75-
private static Map<MarshallLocation, TimestampFormatTrait.Format> defaultTimestampFormats() {
75+
public static Map<MarshallLocation, TimestampFormatTrait.Format> defaultTimestampFormats() {
7676
Map<MarshallLocation, TimestampFormatTrait.Format> formats = new HashMap<>();
7777
// Query doesn't support location traits
7878
formats.put(MarshallLocation.PAYLOAD, TimestampFormatTrait.Format.ISO_8601);
7979
return Collections.unmodifiableMap(formats);
8080
}
81+
8182
}

protocols/aws-query/src/main/java/software/amazon/awssdk/protocols/query/internal/unmarshall/QueryProtocolUnmarshaller.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.awssdk.protocols.query.internal.unmarshall;
1717

18+
import static software.amazon.awssdk.protocols.query.internal.marshall.SimpleTypeQueryMarshaller.defaultTimestampFormats;
19+
1820
import java.util.HashMap;
1921
import java.util.List;
2022
import java.util.Map;
@@ -24,6 +26,7 @@
2426
import software.amazon.awssdk.core.protocol.MarshallingType;
2527
import software.amazon.awssdk.http.AbortableInputStream;
2628
import software.amazon.awssdk.http.SdkHttpFullResponse;
29+
import software.amazon.awssdk.protocols.core.StringToInstant;
2730
import software.amazon.awssdk.protocols.core.StringToValueConverter;
2831
import software.amazon.awssdk.utils.CollectionUtils;
2932
import software.amazon.awssdk.utils.Pair;
@@ -49,6 +52,8 @@ public class QueryProtocolUnmarshaller<TypeT extends SdkPojo> {
4952
.unmarshaller(MarshallingType.DOUBLE, new SimpleTypeQueryUnmarshaller<>(StringToValueConverter.TO_DOUBLE))
5053
.unmarshaller(MarshallingType.BOOLEAN, new SimpleTypeQueryUnmarshaller<>(StringToValueConverter.TO_BOOLEAN))
5154
.unmarshaller(MarshallingType.DOUBLE, new SimpleTypeQueryUnmarshaller<>(StringToValueConverter.TO_DOUBLE))
55+
.unmarshaller(MarshallingType.INSTANT,
56+
new SimpleTypeQueryUnmarshaller<>(StringToInstant.create(defaultTimestampFormats())))
5257
.unmarshaller(MarshallingType.SDK_BYTES, new SimpleTypeQueryUnmarshaller<>(StringToValueConverter.TO_SDK_BYTES))
5358
.unmarshaller(MarshallingType.LIST, new ListQueryUnmarshaller())
5459
.unmarshaller(MarshallingType.MAP, new MapQueryUnmarshaller())

protocols/aws-query/src/main/java/software/amazon/awssdk/protocols/query/internal/unmarshall/XmlDomParser.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import javax.xml.stream.XMLInputFactory;
2424
import javax.xml.stream.XMLStreamException;
2525
import javax.xml.stream.events.Attribute;
26-
import javax.xml.stream.events.Characters;
2726
import javax.xml.stream.events.StartElement;
2827
import javax.xml.stream.events.XMLEvent;
2928
import software.amazon.awssdk.annotations.SdkInternalApi;
@@ -46,7 +45,7 @@ public static XmlElement parse(InputStream inputStream) throws XMLStreamExceptio
4645
do {
4746
nextEvent = reader.nextEvent();
4847
} while (reader.hasNext() && !nextEvent.isStartElement());
49-
return parseElement((StartElement) nextEvent, reader);
48+
return parseElement(nextEvent.asStartElement(), reader);
5049
}
5150

5251
/**
@@ -64,14 +63,34 @@ private static XmlElement parseElement(StartElement startElement, XMLEventReader
6463
do {
6564
nextEvent = reader.nextEvent();
6665
if (nextEvent.isStartElement()) {
67-
elementBuilder.addChildElement(parseElement((StartElement) nextEvent, reader));
66+
elementBuilder.addChildElement(parseElement(nextEvent.asStartElement(), reader));
6867
} else if (nextEvent.isCharacters()) {
69-
elementBuilder.textContent(((Characters) nextEvent).getData());
68+
elementBuilder.textContent(readText(reader, nextEvent.asCharacters().getData()));
7069
}
7170
} while (!nextEvent.isEndElement());
7271
return elementBuilder.build();
7372
}
7473

74+
/**
75+
* Reads all characters until the next end element event.
76+
*
77+
* @param eventReader Reader to read from.
78+
* @param firstChunk Initial character data that's already been read.
79+
* @return String with all character data concatenated.
80+
*/
81+
private static String readText(XMLEventReader eventReader, String firstChunk) throws XMLStreamException {
82+
StringBuilder sb = new StringBuilder(firstChunk);
83+
while (true) {
84+
XMLEvent event = eventReader.peek();
85+
if (event.isCharacters()) {
86+
eventReader.nextEvent();
87+
sb.append(event.asCharacters().getData());
88+
} else {
89+
return sb.toString();
90+
}
91+
}
92+
}
93+
7594
/**
7695
* Converts an iterator of {@link Attribute}s to a map.
7796
*

test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/ec2-output.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"given": {
55
"response": {
66
"status_code": 200,
7-
"body": "<AllTypesResponse><stringMember>stringVal</stringMember><integerMember>42</integerMember><floatMember>1.234</floatMember><doubleMember>5.678</doubleMember><longMember>9001</longMember></AllTypesResponse>"
7+
"body": "<AllTypesResponse><stringMember>stringVal</stringMember><integerMember>42</integerMember><floatMember>1.234</floatMember><doubleMember>5.678</doubleMember><longMember>9001</longMember><timestampMember>2015-01-25T08:00:12Z</timestampMember></AllTypesResponse>"
88
}
99
},
1010
"when": {
@@ -17,7 +17,8 @@
1717
"integerMember": 42,
1818
"floatMember": 1.234,
1919
"doubleMember": 5.678,
20-
"longMember": 9001
20+
"longMember": 9001,
21+
"timestampMember": 1422172812000
2122
}
2223
}
2324
},

test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/query-output.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"given": {
55
"response": {
66
"status_code": 200,
7-
"body": "<AllTypesResponse><AllTypesResult><stringMember>stringVal</stringMember><integerMember>42</integerMember><floatMember>1.234</floatMember><doubleMember>5.678</doubleMember><longMember>9001</longMember></AllTypesResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></AllTypesResponse>"
7+
"body": "<AllTypesResponse><AllTypesResult><stringMember>stringVal</stringMember><integerMember>42</integerMember><floatMember>1.234</floatMember><doubleMember>5.678</doubleMember><longMember>9001</longMember><timestampMember>2015-01-25T08:00:12Z</timestampMember></AllTypesResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></AllTypesResponse>"
88
}
99
},
1010
"when": {
@@ -17,7 +17,8 @@
1717
"integerMember": 42,
1818
"floatMember": 1.234,
1919
"doubleMember": 5.678,
20-
"longMember": 9001
20+
"longMember": 9001,
21+
"timestampMember": 1422172812000
2122
}
2223
}
2324
},

0 commit comments

Comments
 (0)