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
AUTO_DETECT_SETTERS no effect on deserialization #1071
Comments
Quick correction: enabling 'PROPAGATE_TRANSIENT_MARKER' does work insofar as everything gets disabled. So the setters got disabled as well! But enabling a getter using '@JsonGetter' also enables the setter. |
@josefguenther The way annotations on setters, getters work is that if only one annotation (like Think of it this way: Jackson tries to create a logical property instance, and then gather all information for it. With all information available, it will then try to figure out intent from minimal amount of information. Having said that, your original case where you are disabling auto-detection for setters and fields should indeed prevent deserialization. Would it be possible to create a stand-alone test method, from code you included above, which recreates the problem only using |
Ok I went ahead and made a test project for you. I was able to determine a few things:
Summary:
Attached is the test project: |
@cowtowncoder Any update? Were you able to confirm? As an aside on the @JsonProperty annotation, that is fine. I understand it. But setting a @JsonGetter should not be the same thing as @JsonProperty -- I do not expect it to automatically enable @JsonSetter as well wethout even specifying it! There should be a setting to turn off this 'feature'... Basically my model has about 50 @JsonIgnore annotations -- one for each property and most setters. It is VERY annoying. |
@josefguenther Haven't had time yet unfortunately. As to About the only difference from So: for all practical purposes, This is not to say that visibility handling could not have issues; I hope to find time to look into this issue in near future. One more thing that might be helpful, in general:
to actually prevent deserialization, and only allow serialization. This feature was added in Jackson 2.6. |
At this point I would need a unit test reproducing remaining problem (if one still exists) against later version like 2.8.7. |
I have globally disabled setters like so:
I have also tried using the ObjectMapper to configure like so:
I have also attempted to disable setters on my entity like so:
I can disable getters in the above manner and it works, ie, the fields (in this case 'something') do not get serialized.
When I deserialize some json specifying 'something', IT WILL CONTINUE TO USE THE SETTER METHOD.
I have only been able to successfully ignore the 'something' setter method like this:
I tried enabling 'PROPAGATE_TRANSIENT_MARKER' which from what I understand may disable the setter (since my field is marked as transient), that also failed to disable the setter (and getter for that matter, I guess I don't understand that property).
I also attempted disabling 'USE_GETTERS_AS_SETTERS', but that had no effect either.
Just an FYI: I am using jackson-databind-2.6.4. I am also using Spring (4.2.4). I was not able to test databind 2.7.0-rcX since it threw exceptions.
The text was updated successfully, but these errors were encountered: