-
-
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
@JsonValue
fails for Java Record
#3063
Comments
Adding the following code works around the problem (though ideologically, I'd prefer to serialize the return value of the getter than the field):
|
Very likely related to the general issue (hoped to be tackled in 2.13) of matching On plus side, if so, would get solved along with quite a few other problems. |
@cowtowncoder if I read this issue correctly, then this appears to be similar to an issue in Scala. Java Records are similar to Scala Case Classes. In a Case Class, the constructor params are automatically accessible publicly - essentially Scala compiler creates a scala class with a field and a method with the name of the field. Annotations are added to the field unless you use a special form of the annotation ( So the ask on my part, is would it be possible to have jackson-databind PojoPropertiesCollector look for |
@pjfanning I think this would be part of the big rewrite of Creator-vs-Properties introspection that I was hoping to do for 2.13 but did not have time for. So got pushed forward. Handling of One thing that might be help would be reproducing this with regular |
@cowtowncoder thanks for the update. My comment above was really an enhancement request so that |
They are already, since Jackson 2.9 (see #1428). |
thanks @cowtowncoder - must be something else going on that is causing the scala 3 stuff not to work |
@cowwoc you can remove the
A TrickSince this issue is caused by (auto-)propagation of annotation on Records components, we learn that the decision to propagate the annotation to either field and/or accessor method is decided by the Since
Then this will then work:
|
@JsonValue
fails for Java Record
Ok I think I know how this can be fixed quite easily: |
Fixed in 2.14 for 2.14.2. |
@cowwoc please take note of the following gotcha for the workaround you used i.e.:
The fix c23f772 for
|
@yihtserns Got it. Thanks for the head's up. |
Hmmh. Ok that is bit unfortunate wrt compatibility, although not sure if anything can be done about it. |
@cowtowncoder Eh your fix for
Sorry for any confusion. |
@yihtserns ah yes. My bad; I did realize it after writing. Thank you for confirming. |
### What changes were proposed in this pull request? This pr aims upgrade `Jackson` related dependencies to 2.14.2 ### Why are the changes needed? This version include some bug fix and improvement of databind, such as: - FasterXML/jackson-databind#3063 - FasterXML/jackson-databind#3699 The full release notes as follows: - https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.14.2 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass Github Actions Closes #39898 from LuciferYang/SPARK-42354. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
### What changes were proposed in this pull request? This pr aims upgrade `Jackson` related dependencies to 2.14.2 ### Why are the changes needed? This version include some bug fix and improvement of databind, such as: - FasterXML/jackson-databind#3063 - FasterXML/jackson-databind#3699 The full release notes as follows: - https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.14.2 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass Github Actions Closes #39898 from LuciferYang/SPARK-42354. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit eb8b97f) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
### What changes were proposed in this pull request? This pr aims upgrade `Jackson` related dependencies to 2.14.2 ### Why are the changes needed? This version include some bug fix and improvement of databind, such as: - FasterXML/jackson-databind#3063 - FasterXML/jackson-databind#3699 The full release notes as follows: - https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.14.2 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass Github Actions Closes apache#39898 from LuciferYang/SPARK-42354. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit eb8b97f) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Version information
2.12.1
OpenJDK 15.0.1
To Reproduce
Given:
I am expecting Jackson to serialize the
Map
to JSON but instead I get the following exception:Problem with definition of [AnnotedClass GetLocations]: Multiple 'as-value' properties defined ([field GetLocations#nameToLocation] vs [method GetLocations#nameToLocation()])
The text was updated successfully, but these errors were encountered: