Skip to content

Commit

Permalink
Fix NPE when UserIdentity is null
Browse files Browse the repository at this point in the history
  • Loading branch information
carlzogh committed Oct 7, 2020
1 parent 109a240 commit c2df718
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public static Record toRecordV2(final DynamodbEvent.DynamodbStreamRecord record)
.eventSource(record.getEventSource())
.eventVersion(record.getEventVersion())
.userIdentity(
DynamodbIdentityTransformer.toIdentityV2(record.getUserIdentity())
record.getUserIdentity() != null
? DynamodbIdentityTransformer.toIdentityV2(record.getUserIdentity())
: null
)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ public void testToRecordV2() {
Assertions.assertEquals(record_v2, convertedRecord);
}

@Test
public void testToRecordV2WhenUserIdentityIsNull() {
DynamodbEvent.DynamodbStreamRecord record = record_event.clone();
record.setUserIdentity(null);

Assertions.assertDoesNotThrow(() -> {
DynamodbRecordTransformer.toRecordV2(record);
});
}

}

0 comments on commit c2df718

Please sign in to comment.