orika-mapper/orika

HashMap key and value populated with null by default, with size of hashmap as 1

Opened this issue · 0 comments

I am mapping a List to a HashMap of <String, List> between class Source and DestinationDto.

Source -

public class Source{

private Integer id;
private Integer itemId;
private String name;
private Timestamp updateTime;
private Timestamp createTime;

private List<Object1> surfaces;

// getters and setters

}

Destination -

public class DestinationDto {

private Integer id;
private String name;
private Integer itemId;
private Map<String, List<Object2>> destMap;

// getters and setters
}

I am using a custom mapper -

mapperFactory .classMap(Source.class, DestinationDto.class)
.customize(new CustomMapper<Source, DestinationDto>() {
@OverRide
public void mapAtoB(Source source,
DestinationDto dest, MappingContext context) {

                Map<String, List<Object2>> map = DestinationDto.getdestMap();
                // here map, that I get has null key and null value in it and the size of map is 1. But, should not the size of hashmap 
                 be zero, with hashmap assigned to null initially? Because of this reason, I have to explicitly remove 
                 null key from hashMap using map.remove(null); 

        .byDefault()
        .register();

Any thoughts on this? Do we need to fix this bug?