Skip to content

Jackson2ObjectMapperBuilder's modulesToInstall function does not eventually override the default configuration #22576

Closed
@elue

Description

@elue

Spring Boot version: 2.1.2.RELEASE

The Jackson2ObjectMapperBuilder's modulesToInstall documentation says

 *Specify one or more modules to be registered with the {@link ObjectMapper}.
 * <p>Modules specified here will be registered after
 * Spring's autodetection of JSR-310 and Joda-Time, or Jackson's
 * finding of modules (see {@link #findModulesViaServiceLoader}),
 * allowing to eventually override their configuration.

But when we have this config:

    @Bean
    public ObjectMapper restApiObjectMapper(final Jackson2ObjectMapperBuilder builder,
                                            final LenientOffsetDateTimeDeserializer offsetDateTimeDeserializer) {
        final JavaTimeModule javaTimeModule = new JavaTimeModule();
        javaTimeModule.addDeserializer(OffsetDateTime.class, offsetDateTimeDeserializer);

        builder.modulesToInstall(javaTimeModule);
        builder.failOnUnknownProperties(false);
        builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        return builder.build();
    }

It is expect that the custom DateTimeDeserializer will get picked up. But still the default one's are used and leading to json parse errors.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions