-
-
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
Implementing #1467: Support for @JsonUnwrapped in @JsonCreators #4271
Conversation
src/main/java/com/fasterxml/jackson/databind/deser/impl/UnwrappedPropertyHandler.java
Outdated
Show resolved
Hide resolved
import com.fasterxml.jackson.databind.deser.SettableBeanProperty; | ||
import com.fasterxml.jackson.databind.util.NameTransformer; | ||
import com.fasterxml.jackson.databind.util.TokenBuffer; | ||
|
||
import java.io.IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move these back to where they were? (I assume IDE just reordered them automatically).
(we finally have Coding Style Guide -> https://github.com/FasterXML/jackson/blob/master/contribution/jackson-coding-style-guide.md
that explains intended ordering)
src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
Outdated
Show resolved
Hide resolved
src/test/java/com/fasterxml/jackson/databind/struct/UnwrappedCreatorParam265Test.java
Show resolved
Hide resolved
src/test/java/com/fasterxml/jackson/databind/struct/TestUnwrappedWithJsonCreator.java
Outdated
Show resolved
Hide resolved
Whoa! Impressive work. I share your suspicion wrt test coverage (lack thereof), but it is what it is. I'd need to read this through with more thought and focus to see if there's anything specifically that wouldn't work (or be against design). In the meantime I added some notes on code style issues (which are obviously not super important but might as well mention now). Also, assuming we get through this to merge it, one thing needed (if not already done) is CLA: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf which we need before merging the first contribution. It's usually easiest to print, fill & sign, scan/photo, email to |
src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithJsonUnwrappedTest.java
Outdated
Show resolved
Hide resolved
@cowtowncoder I sent the signed CLA to Just to verify, here it says to email the CLA to |
src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
Outdated
Show resolved
Hide resolved
protected final List<SettableBeanProperty> _properties; | ||
protected final Set<String> _unwrappedPropertyNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and if isUnwrapped()
is not actually needed, can drop this Set
and code that maintains it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the set and the check!
src/test/java/com/fasterxml/jackson/databind/struct/UnwrappedWithCreatorTest.java
Outdated
Show resolved
Hide resolved
539272d
to
d65dfac
Compare
.../java/com/fasterxml/jackson/databind/struct/UnwrappedPropertyBasedCreatorWithPrefixTest.java
Show resolved
Hide resolved
I noticed a minor issue with the placeholder name: If you use two
I added a test case here: From what I can see, there are three solutions to this:
|
To me (2), adding index for bogus name, sounds reasonable at this point. +1. |
While looking for a stop-gap solution for this in GitHub, I found this (usage) rather straightforward solution for Looking forward to having this merged. Thank you for the contribution! |
@cowtowncoder, what's the status of this PR? |
Quick note: this would need to be re-based on 2.18 which may be tricky due to major POJO property introspection rewrite (or might be easy). This won't be merged in 2.17 due to high risk of regression for patch. |
Re-based, but now there are conflicts to resolve... not sure I have time to tackle those right now. |
Ok. Had a look and... yeah, no. These merge conflicts are actually beyond my repairing. Unfortunately those 2 classes were heavily modified by this PR. But if anyone has time and interest to reconstruct this PR based off 2.18, we could consider it (or, in near future when 2.18 released, against 2.19). |
I'm sick at the moment, but maybe I can give it a shot later this week. I was just waiting for the PR to be merged tho, as far as I was concerned nothing was left to do, right? As far as the last comment, I had already implemented the second solution, I was just presenting alternatives. Maybe that caused a misunderstanding, sorry! |
@fxshlein Unfortunately as per my comment, PR's changes heavily conflict with the POJO property discovery rewrite in 2.18. And being essentially a new feature (although not technically API change), I wouldn't want to sneak it in a patch release of 2.17 -- it needs to go in a .0 version of a minor version. Right now that'd be 2.18.0 via I wasn't able to quite see how to resolve conflicts of this PR, but of course if you can figure it out, we can use this PR. Alternatively it may be simpler (if more work) to start with 2.18 and re-create changes -- logic of POJO property discovery hasn't changed (minus bug fixes), just implementation. |
27ce184
to
22cb7ee
Compare
haha, I already figured when I saw the 2.18 RC a few days ago. Changed it to 2.19! |
@cowtowncoder I changed the base branch to 2.19, seems to work without conflicts. I guess this could be merged now that the 2.19 branch exists, right? |
Is there any update on this or reason why this isn't getting merged? Looks all green and all feedback addressed. |
We need proper planning wrt timing on when features get merged.
Not to mention |
Note that the target branch for this PR is the development branch for |
This is on my TODO list -- I have been bit overloaded with backlogs but should be able to check this out this week. Thank you everyone for your patience! |
Went over this once, made tiny stylistic changes but want to go over the thing once more and then get merged. My spider sense is tingling wrt this being possibly risky, still, but at the same time all tests, added ones and old, pass -- and this would solve one of only 8 "most-wanted" issues, so clearly many users would like to see it come available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Bit worried about possible name clashes, POJOPropertiesCollector
, but can deal with problems if they arise.
Great job and patience @fxshlein ✌🏼! |
Agreed. Now if I can get this cleanly merged into 3.0 that's the real test... except for one aspect, got it done. So am hopeful still. |
…ss to DeserializationContext
(fixes #1467 -- one of oldest highly-voted-for open issues)
I was more or less just messing around with an approach to solve this for now without the big refactor mentioned in the issue. Perhaps this is already fine? The test I added is green at least, but I have no idea what I might have missed. After all, if an "object with three properties" test covered a considerable amount of jackson's feature set, I wouldn't be using it... 😆