moip-sdk-java-le icon indicating copy to clipboard operation
moip-sdk-java-le copied to clipboard

fix(serialization): preventing NPE when Customer.moipAccount is null during serialization to String(Json)

Open fzoro opened this issue 6 years ago • 0 comments

Serialization with jackson fails when moipAccount field is null.

Kotlin code to reproduce the issue.

    // all fields null(which is ok)
    val c = Customer()
    val objectMapper = ObjectMapper()
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
    val json = objectMapper.writeValueAsString(c) // throws NPE, since it evaluates all fields.

fzoro avatar Feb 25 '19 23:02 fzoro