Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"category": "Amazon DynamoDB Enhanced",
"contributor": "reed53",
"type": "bugfix",
"description": "Empty beans are now preserved through serialization and deserialization"
}
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,7 @@ public StaticTableMetadata tableMetadata() {

@Override
public T mapToItem(Map<String, AttributeValue> attributeMap) {
// Lazily instantiate the builder once we have an attribute to write
B builder = null;
B builder = constructNewBuilder();
Map<FlattenedMapper<T, B, ?>, Map<String, AttributeValue>> flattenedAttributeValuesMap = new LinkedHashMap<>();

for (Map.Entry<String, AttributeValue> entry : attributeMap.entrySet()) {
Expand All @@ -451,9 +450,6 @@ public T mapToItem(Map<String, AttributeValue> attributeMap) {
ResolvedImmutableAttribute<T, B> attributeMapper = indexedMappers.get(key);

if (attributeMapper != null) {
if (builder == null) {
builder = constructNewBuilder();
}

attributeMapper.updateItemMethod().accept(builder, value);
} else {
Expand All @@ -479,7 +475,7 @@ public T mapToItem(Map<String, AttributeValue> attributeMap) {
builder = entry.getKey().mapToItem(builder, this::constructNewBuilder, entry.getValue());
}

return builder == null ? null : buildItemFunction.apply(builder);
return buildItemFunction.apply(builder);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ private <R> void verifyNullAttribute(EnhancedType<R> attributeType,
assertThat(resultMap, is(expectedMap));

FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
assertThat(resultItem, is(nullValue()));
assertThat(resultItem, is(FakeMappedItem.builder().build()));
}

private <R> void verifyNullableAttribute(EnhancedType<R> attributeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ private <R> void verifyNullAttribute(EnhancedType<R> attributeType,
assertThat(resultMap, is(expectedMap));

FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
assertThat(resultItem, is(nullValue()));
assertThat(resultItem, is(FakeMappedItem.builder().build()));
}

private <R> void verifyNullableAttribute(EnhancedType<R> attributeType,
Expand Down