FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

[Avro] JsonInclude.Include.NON_NULL does not use default values #165

Open amorimjuliana opened 5 years ago

amorimjuliana commented 5 years ago

In the following example, I'd expect that the default value defined for the property map would be used. Instead, null is passed, which produces an error as null is not allowed for this field.

Schema

{"type": "map", "values": "string", "default": []}

POJO

class Foo {
    @JsonProperty("map")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    Map<String, String> getMap();
}

Error

com.fasterxml.jackson.databind.JsonMappingException: null of map in field map of Foo
cowtowncoder commented 5 years ago

Thank you for reporting the problem!

Handling of default values is probably bit incomplete, but it should be possible to improve that esp. for case of of empty array/Collection.

amorimjuliana commented 5 years ago

Thanks for the feedback @cowtowncoder :)

Please let me know if I can help in any way.