-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
Given the following class:
package org.example.mongoemptymaptest.model;
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.DocumentReference;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Data
@Builder
@Document(collection = "parent_documents")
public class ParentDocument {
@Id
@Builder.Default
UUID id = UUID.randomUUID();
@NonNull
@Builder.Default
@DBRef
Map<String, ChildDocument> dbRefChildren = new HashMap<>();
@NonNull
@Builder.Default
@DBRef(lazy = true)
Map<String, ChildDocument> lazyDbRefChildren = new HashMap<>();
@NonNull
@Builder.Default
@DocumentReference
Map<String, ChildDocument> documentReferenceChildren = new HashMap<>();
@NonNull
@Builder.Default
@DocumentReference(lazy = true)
Map<String, ChildDocument> lazyDocumentReferenceChildren = new HashMap<>();
}
The document will fail to deserialize if documentReferenceChildren
is an empty map, and will fail to properly resolve the map for lazyDocumentReferenceChildren
if it is an empty map. In that case, getLazyDocumentReferenceChildren().values()
method will return null.
Unit tests illustrating the bug: https://github.com/bamapookie/MongoEmptyMapTest
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged