Skip to content

MapperFeature.AUTO_DETECT_XXX do not work if all disabled #1947

@saladinkzn

Description

@saladinkzn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions