FasterXML / jackson-module-kotlin

Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Apache License 2.0
1.12k stars 175 forks source link

Bug fix: Don't serialize value class if their outer class has JsonInclude.NonNull annotation(#625) #644

Closed tmdgusya closed 1 year ago

tmdgusya commented 1 year ago

The problem of #625 will resolved by this P.R.


There is one more problem with that. If the ObjectMapper is configured with JsonInclude.Nonnull, then the ObjectMapper will not serialize the property. However, the ObjectMapper is serializing the property. I think it can be easily resolved if I know how to get the serializationInclusion values of the ObjectMapper in the KotlinModule class.

cowtowncoder commented 1 year ago

I'll let @k163377 dig in deeper but it seems to me that this tries approach problem by work-around that is very specific to tested problem. Since usage works with POJOs (Java beans) it seems this should not be necessary; and specifically AnnotationIntrospector should not try to deduce structural information (from enclosing class), ever. It should only get information as requested; it's caller (like BeanSerializerBuilder / -Factory) that should compose information on inclusion to use.

So I'd be suspicious of using this to try to resolve the real problem in #625.

tmdgusya commented 1 year ago

@cowtowncoder I understand your review. So this issue'll be assigned to @k163377 ?

cowtowncoder commented 1 year ago

@tmdgusya @k163377 is one of module maintainers (I am not) so I let him decide; I just added notes of my concerns.

k163377 commented 1 year ago

I have created a PR summarizing the changes mentioned in my comment.

659

I am very sorry, but this PR is closed.