-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix #4938 Allow @JsonCreator
to return null
#4948
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
Conversation
src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
Show resolved
Hide resolved
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.
Need to address case of properties other than those matched as Creator properties: ones collected before Creator called and ones that may come after it's called.
src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
Outdated
Show resolved
Hide resolved
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||
.readValue(in); | ||
// Check if read all the bytes | ||
assertEquals(-1, in.read()); |
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.
This approach does not work: Jackson parsers buffer content so all content being read from InputStream
does not actually necessarily mean all has been consumed.
There is a method in JsonParser
for pushing back "unread" content but...
Instead of this, you could just enable DeserializationFeature.FAIL_ON_TRAILING_TOKENS
to verify there is no more content to be read (tokens). That should catch the issue.
@cowtowncoder If you see current build failure there are two tests failing trying to handle unknown properties in following ways...
Both reaches BeanDeserializer.handleUnknownVanilla(), could it be what we already want? Or are you saying we need the execution to continue to go on further down, to like ... ![]() ... here? |
I think that if But that handling should be extracted to a helper method just to keep logic cleaner and possibly change. And pass already collected information. |
@cowtowncoder Just some updates,
|
Alright, I think I'm stuck at trying to find the proper place/timing for method extraction. No rush for this work to be done, but any opinion much appreciated! 😆 |
I'm happy to have a look -- might take a while as I'm going for 1 week vacation tomorrow. But will help when I get back (unless I have extra time today). |
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
@JooHyukKim Finally had time to get back to this one -- changed things slightly, the way I think it should work, and I think this is ready to be merged. Will leave open, merge tomorrow, unless you want to change things further. |
Assuming this is fine, merging. |
Sorry late reply, yes, seems okay to merge! |
resolves #4938