Skip to content
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

MapperFeature.AUTO_DETECT_XXX do not work if all disabled #1947

Closed
saladinkzn opened this issue Feb 27, 2018 · 1 comment
Closed

MapperFeature.AUTO_DETECT_XXX do not work if all disabled #1947

saladinkzn opened this issue Feb 27, 2018 · 1 comment

Comments

@saladinkzn
Copy link

saladinkzn commented Feb 27, 2018

We use ObjectMapper.disable(MapperFeature.AUTO_DETECT_XXX) to disable autodetection of all kind of property accessors. After updating to jackson 2.9 I noticed that this method doesn't work anymore and visibility is reset to default (ANY for getters/is getters and public for other)

I've created a repository that shows this issue:
https://github.com/saladinkzn/jackson-auto-detect-issue

If run without changes it produces following output:

{"shouldBeDetected":0,"shouldNotBeDetected":null}
[Visibility: getter=PUBLIC_ONLY,isGetter=PUBLIC_ONLY,setter=ANY,creator=ANY,field=PUBLIC_ONLY]

But if I comment out any disable line (e.g. AUTO_DETECT_IS_GETTER) I receive following output:

{"shouldBeDetected":0}
[Visibility: getter=NONE,isGetter=PUBLIC_ONLY,setter=NONE,creator=NONE,field=NONE]

I guess the reason is that getDefaultVisibilityChecker explicitly skips disabling if none of AUTO_DETECT features is enabled.
https://github.com/FasterXML/jackson-databind/blob/jackson-databind-2.9.4/src/main/java/com/fasterxml/jackson/databind/cfg/MapperConfigBase.java#L675

P.S.
I see that this code is rewritten in master branch already, so I'll try to reproduce my issue on it.

@cowtowncoder
Copy link
Member

Yes, I can reproduce this. Looks like optimization in code (trying to avoid calculations if "no change to defaults") has wrong logic.

@cowtowncoder cowtowncoder changed the title MapperFeature.AUTO_DETECT_XXX do not work if applied all at once. MapperFeature.AUTO_DETECT_XXX do not work if all disabled Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants