Skip to content

Commit 52a2845

Browse files
yongruigaoYongrui Gao
andauthored
Add null check on the input of DynamodbAttributeValueTransformer.toAttributeValueMapV1 (#254)
Co-authored-by: Yongrui Gao <yongru@amazon.com>
1 parent 66706aa commit 52a2845

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/dynamodb/DynamodbAttributeValueTransformer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public static AttributeValue toAttributeValueV1(final com.amazonaws.services.lam
6363
public static Map<String, AttributeValue> toAttributeValueMapV1(
6464
final Map<String, com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue> attributeValueMap
6565
) {
66+
if (attributeValueMap == null) {
67+
return null;
68+
}
69+
6670
return attributeValueMap
6771
.entrySet()
6872
.stream()

aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/dynamodb/DynamodbAttributeValueTransformerTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,9 @@ public void testToAttributeValueV1_EmptyV1ObjectWhenEmpty_L() {
313313
DynamodbAttributeValueTransformer.toAttributeValueV1(new AttributeValue().withL(Collections.emptyList())));
314314
}
315315

316+
@Test
317+
public void testToAttributeValueMapV1_NullV1AttributeValueMapWhenNullEventAttributeValueMap() {
318+
Assertions.assertNull(DynamodbAttributeValueTransformer.toAttributeValueMapV1(null));
319+
}
320+
316321
}

0 commit comments

Comments
 (0)