-
-
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
deserialized JsonAnySetter field is null #4508
Comments
Since
Could you provide Java-only reproduction to make sure it is |
Right; either this needs to move to But I think there is probably already an issue wrt |
I also ran into this issue, it can be fixed by writing |
Ah, thank u for sharing @kotcrab ! |
Some background. As @kotcrab described above, this is regression caused by annotations module change, the annotation change was meant to be pre-requisite for the databind-module's Allow 'JsonAnySetter' to flow through JsonCreator #562 issue. I started writing PR #4366 to support the databind-module change, but stopped to allow room for Property Introspection Rewrite in #4515. As per solution, either....
|
Wait, what is that
wouldn't that mean "ignore this any setter/getter"? That should not be added there. |
@cowtowncoder No, it wouldn’t. It means ignoring additionalProperties itself in serialization and deserialization. However, the other two annotations, @JsonAnySetter and @JsonAnyGetter, will be used for all unrecognized properties. All unrecognized properties will be added to the map for serialization and obtained from the map for deserialization. |
JsonAnyGetter/Setter will already not appear in the serialization/deserialization as its own property. The JsonIgnore is not necessary and should not be there |
@MaximValeev it is possible But as to proper fix: I think #562 would be that (maybe via #4558) -- to may Alternatively, yes, Kotlin side should annotate Field to use. |
I understood that there is nothing to do in |
Caution : this is not about what has caused the change in behavior in 2.17. Instead, this is about making it work in 2.18. So I found out that My intuition is that, below implementation in // [databind#562] since 2.18 : Respect @JsonAnySetter in @JsonCreator
if (_anyParamSetter != null) {
Object anySetterParameterObject = _anyParamSetter.createParameterObject();
for (PropertyValue pv = _anyParamBuffered; pv != null; pv = pv.next) {
pv.setValue(anySetterParameterObject);
}
_creatorParameters[_anyParamSetter.getParameterIndex()] = anySetterParameterObject;
} ... should be moved somewhere to make it work? |
Ideally we should remove the need for KotlinValueInstantiator overrides. But on short term, yes, may need to update override in question. |
I'm seeing this issue when I tried to upgrade to My class has lombok in it, but it looks like this: @Data
public class MyClass {
private final int id;
private final String name;
@JsonAnyGetter
@JsonAnySetter
private final Map<String, Object> params;
} |
@mikethecalamity that is unfortunately not a full reproduction; would need to add calling code, as well as replace Lombok annotations with processed code (one JVM loads). If this could be reproduced with plain-non-Lombok-Java that'd be great since so far assumption has been this is Kotlin-specific. |
As @kotcrab describes, this is Kotlin specific issue, but caused by FasterXML/jackson-annotations#242 in 2.17 which was to support a |
Since this is regression, would you consider reverting FasterXML/jackson-annotations#242 in 2.17 version, @cowtowncoder? I know release is not easy, so no pressure tho. And we may apply the annotations module change only to 2.18, try fixing things up in 2.18. If we try to fix things without change in Kotlin module, #4720 would do the fix? |
@JooHyukKim No; annotations are special case where we really cannot change things in patch release, so 2.17.x cannot be changed except in exceptional circumstances. Same now goes for 2.18.x, actually, since 2.18.0 is released. But if #4720 can fix this issue let's work on getting that done. I am bit worried tho about Kotlin annotation handling, wrt replication of annotations to accessors: we seem to be hitting problems related to that. |
I think we are better off not making changes to Kotlin module, as we do not strictly force using same version of databind and kotlin modules.
Can you share some pointers that we can follow? |
@JooHyukKim I was thinking of FasterXML/jackson-annotations#258 that had to be reverted; not sure how closely related these things are. As to making changes to Kotlin module: agreed that coordinated changes wouldn't work. But if there was Kotlin-module-only fix (requiring no changes here), that'd be tempting. |
Fix via #4720, will be in 2.18.1 |
I may be wrong but it'd look like this might be causing/dup of: |
Running Parcelo in a container via our current Dockerfile revealed that "uses-sdk" fields were not being parsed from applications' Android manifests, effectively preventing app uploads since the targetSdk property of uses-sdk is required by Parcelo. This bug wasn't caught until now because it only seems to manifest itself when running via the Dockerfile; running locally as in our recommended development environment does not have the issue. The Jackson 2.18.0 upgrade has not yet been included in a production release, so it's uncertain whether the issue would have surfaced in our production environment. We tracked the issue down to a regression in Jackson 2.18.0. The exact cause is unknown. However, a number of seemingly related issues were reported for Jackson 2.18.0 [1], so we plan to closely monitor those issues and test upcoming Jackson releases carefully to prevent breakage. [1]: See below: - FasterXML/jackson-module-kotlin#841 - FasterXML/jackson-module-kotlin#842 - FasterXML/jackson-module-kotlin#843 - FasterXML/jackson-module-kotlin#832 - FasterXML/jackson-databind#4508 - FasterXML/jackson-databind#4752
Running Parcelo in a container via our current Dockerfile revealed that "uses-sdk" fields were not being parsed from applications' Android manifests, effectively preventing app uploads since the targetSdk property of uses-sdk is required by Parcelo. This bug wasn't caught until now because it only seems to manifest itself when running via the Dockerfile; running locally as in our recommended development environment does not have the issue. The Jackson 2.18.0 upgrade has not yet been included in a production release, so it's uncertain whether the issue would have surfaced in our production environment. We tracked the issue down to a regression in Jackson 2.18.0. The exact cause is unknown. However, a number of seemingly related issues were reported for Jackson 2.18.0 [1], so we plan to closely monitor those issues and test upcoming Jackson releases carefully to prevent breakage. [1]: See below: - FasterXML/jackson-module-kotlin#841 - FasterXML/jackson-module-kotlin#842 - FasterXML/jackson-module-kotlin#843 - FasterXML/jackson-module-kotlin#832 - FasterXML/jackson-databind#4508 - FasterXML/jackson-databind#4752
Search before asking
Describe the bug
I have kotlin data class
and json
Before jackson 2.17.0 the json deserialized into class correctly. any_other_data put to additionalProperties map.
On 2.17.0 version i have additionalProperties == null after the deserialization.
Version Information
2.17.0
Expected behavior
i expected that field annotated with @JsonAnySetter will be filled with all the undeclared fields
The text was updated successfully, but these errors were encountered: