-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter method only got called once if the field is null when using @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SomeFieldFilter.class)
#3481
Comments
Thank you for reporting this issue. It sounds like possible bug. It would be great to have a reproduction (unit test), if possible. |
Ah, ok. This is a feature, not bug -- you are right, null check is only done once: this is an optimization to make Calling filtering for repeated |
Thank you very much for the prompt reply. It's great that we have more optimized code running faster. I believe So, with this optimization, it behaves like this for Which version introduced this optimization? Thanks in advance. |
This has always been the behavior, since the addition of Given above I don't think I have time to dig into whether change would be possible. But if you want to see if that is possible and propose a patch, I am not against that. I would, however, want to know why such a change is beneficial: that is, what exactly would be the use case? |
I see. Thank you very much for the explanation. I guess I didn't notice it before because the setting was only serializing Actually, the results of Yes, I can take a look to see if it's feasible. |
@AmiDavidW I don't remember specifically where, but you can search for But as to filtering: if your filters are more complicated, you may want to check out use of https://www.logicbig.com/tutorials/misc/jackson/json-filter-annotation.html |
Thank you very much. I will check both |
URL: FasterXML#3481 1. Check JsonInclude.Include.CUSTOM filter before serialize null values (BeanPropertyWriter). 2. Make JsonInclude.Include.CUSTOM and suppressNull independent (PropertyBuilder). 3. Adapt the unit tests (JsonIncludeCustomTest).
URL: FasterXML#3481 1. Check JsonInclude.Include.CUSTOM filter before serializing null values (BeanPropertyWriter). 2. Make JsonInclude.Include.CUSTOM and suppressNull independent (PropertyBuilder). 3. Adapt the unit tests (JsonIncludeCustomTest).
@cowtowncoder I provided a fix. Please review it and let me know if I need to make changes. |
@cowtowncoder I signed and sent the CLA. Please let me know if there's anything else I need to do. |
Thank you. I hope to have time to check the PR in near future -- thank you for contributing it and sending CLA! |
Added a note on PR; apologies for slow followup. |
No worries, @cowtowncoder. Thanks a lot for checking it. I replied on the PR #3486 |
URL: FasterXML#3481 1. Check JsonInclude.Include.CUSTOM filter before serializing null values (BeanPropertyWriter). 2. Make JsonInclude.Include.CUSTOM and suppressNull independent (PropertyBuilder). 3. Adapt the unit tests (JsonIncludeCustomTest).
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SomeFieldFilter.class)
Describe the bug
The filter method only get called once if the field value is
NULL
,when using
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SomeFieldFilter.class)
Version information
2.12.6.1
To Reproduce
ObjectDto
which has aNULL
value forfieldDto
:Send requests to the endpoint.
The first time, the
equals()
method ofSomeFieldFilter
is called during the serialization.The same method never get called for the HTTP requests after.
For instances that have a
non-NULL
value forfieldDto
, theequals()
method of SomeFieldFilter` gets called all the time during the serializationExpected behavior
For instances that have a
NULL
value forfieldDto
, theequals()
method ofSomeFieldFilter
also gets called all the time during the serializationAdditional context
N/A
The text was updated successfully, but these errors were encountered: