diff --git a/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java b/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java index abf0e91a..30d1d9e6 100644 --- a/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java +++ b/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java @@ -36,6 +36,7 @@ import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; import software.amazon.awssdk.core.document.Document; +import software.amazon.awssdk.core.document.Document.ListBuilder; import software.amazon.awssdk.core.document.Document.MapBuilder; import software.amazon.awssdk.core.protocol.MarshallingType; import software.amazon.awssdk.core.traits.ListTrait; @@ -219,11 +220,11 @@ private Document readDocument(SdkField field, JsonParser p, DeserializationCo case VALUE_NUMBER_INT: return Document.fromNumber(p.getText()); case START_ARRAY: { - List documents = new ArrayList<>(); + ListBuilder builder = Document.listBuilder(); while (p.nextToken() != JsonToken.END_ARRAY) { - documents.add(readDocument(field, p, ctxt)); + builder.addDocument(readDocument(field, p, ctxt)); } - return Document.fromList(documents); + return builder.build(); } case START_OBJECT: MapBuilder builder = Document.mapBuilder();