Skip to content

Spring Boot is not respecting Jackson configuration #48382

@mozzer39

Description

@mozzer39

I have a problem with setting a deserialization feature in Jackson 3. With Jackson 3 there's a change in behavior while mapping null values into primitive types. I created a configuration class, but unfortunately it's not working and I still get error while deserialization. What am I missing?

@Configuration
public class JsonMapperConfig {

    @Bean
    @Primary
    JsonMapperBuilderCustomizer jacksonCustomizer() {
        return builder -> builder.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
    }

}

The error I'm getting:

Caused by: tools.jackson.databind.exc.MismatchedInputException: Cannot map `null` into type `int` (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #766] (through reference chain: xxx)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions