jackson-dataformats-binary icon indicating copy to clipboard operation
jackson-dataformats-binary copied to clipboard

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

Open amorimjuliana opened this issue 6 years ago • 2 comments

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

amorimjuliana avatar Jun 19 '19 16:06 amorimjuliana

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.

cowtowncoder avatar Jul 01 '19 22:07 cowtowncoder

Thanks for the feedback @cowtowncoder :)

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

amorimjuliana avatar Jul 02 '19 16:07 amorimjuliana