-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Put back enum field without renaming #4313
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/introspect/POJOPropertiesCollector.java
Show resolved
Hide resolved
if (!prop.hasSetter() | ||
&& Objects.nonNull(prop.getField()) | ||
&& (Objects.equals(_type, prop.getField().getType()) && prop.getPrimaryType().isEnumType()) | ||
) { |
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.
I wonder if there is cleaner solution for this... 🤔
Or just extract method to some where (probably not POJOPropertyBuilder
, it doens't need to know about Enum stuff)
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.
Sorry, I should have noticed -- original "fix" is actually totally wrong.
It applies to properties with Enum value but what we want are properties WITHIN type that has properties.
I am not sure how it would have resolved the problem but I can look into fixing the problem. Odd databind had no test for naming strategy with Enum-valued POJO property.
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.
First thing I think (beyond revert) is to add a test for naming strategy. I can do that.
// test deserialization | ||
AsField4302Bean result = SNAKE_MAPPER.readValue( | ||
a2q("{'some_enum':'SOME_PERSON', 'other_prop':'thisField'}"), AsField4302Bean.class); | ||
assertEquals(AsField4302Enum.SOME_PERSON, result.someEnum); | ||
assertEquals("thisField", result.otherProp); |
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 test corresponds to the failing test in ion module --when there is Enum field, we should keep renaming it, same as before
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.
Right.
Solved via #4314, will close this PR. |
Summary
This PR completes #4311 fix.
This PR fixes behavior introduced by #4311, when Enum is used as field of other class and
POJOPropertiesCollector
tries to rename it via_renameUsing()
, we just drop the field.Notes