Skip to content

Auto-configure Jackson contructor detector to ConstructorDetector.USE_PROPERTIES_BASED by default #26023

Closed
@lpandzic

Description

@lpandzic

I believe Jackson Auto Configuration in Spring should set ConstructorDetector.USE_PROPERTIES_BASED flag out of the box:

objectMapper.setConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector.USE_PROPERTIES_BASED);

Background can be found here: FasterXML/jackson-databind#1498 and my tldr version is (I've been involved since the start of this in 2014...): Due to backwards compatibility concerns this can't be changed in Jackson itself but on the other hand this surprises a lot of Jackson users as the whole Java industry moves slowly forward to immutable by default way of thinking.

With this enabled users should be able to deserialize classes without any exceptions or surprises:

class Foo {
    private final Bar bar;

    Foo(Bar bar) {
        this.bar = bar;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions