ObjectMapper.enable is deprecated since 2.7.x

See original GitHub issue

Describe the bug

According to the docs, we need to use the ObjectMapperCustomizer to customize jackson. Since Jackson 2.13(Quarkus 2.7), the enable(MapperFeature... f) function is deprecated and we should replace it with JsonMapper.builder().enable(...). Sadly we only get a ObjectMapper which doesn’t allow us to use builder().

Expected behavior

A way to use

mapper.enable(
            ACCEPT_CASE_INSENSITIVE_ENUMS,
            ACCEPT_CASE_INSENSITIVE_PROPERTIES,
            ACCEPT_CASE_INSENSITIVE_VALUES
        )

Actual behavior

Deprecation warning.

How to Reproduce?

@Singleton
class JacksonMapperConfig : ObjectMapperCustomizer {
    override fun customize(mapper: ObjectMapper) {
        mapper.registerKotlinModule().enable(
            ACCEPT_CASE_INSENSITIVE_ENUMS,
            ACCEPT_CASE_INSENSITIVE_PROPERTIES,
            ACCEPT_CASE_INSENSITIVE_VALUES
        ).registerModules(
                Builder()
                .configure(NullIsSameAsDefault, true)
                .configure(NullToEmptyCollection, true)
                .configure(NullToEmptyMap, true)
                .build(),
            JavaTimeModule(),
            Jdk8Module(),
            ParameterNamesModule()
        )
    }
}

Output of uname -a or ver

Linux 5.16.8-zen1-1-zen

Output of java -version

openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12) OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)

GraalVM version (if different from Java)

N/A

Quarkus version or git rev

2.7.1

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------ Gradle 7.4 ------------------------------------------------------------ Build time: 2022-02-08 12:14:25 UTC Revision: <unknown> Kotlin: 1.5.31 Groovy: 3.0.9 Ant: Apache Ant™ version 1.10.11 compiled on July 10 2021 JVM: 17.0.1 (Oracle Corporation 17.0.1+12) OS: Linux 5.16.8-zen1-1-zen amd64

Additional information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
geoandcommented, Feb 13, 2022

Interesting… I wonder if it makes sense to wait for Jackson 3.x to make a change with regard to this

2reactions
geoandcommented, Feb 13, 2022

Thanks, I’ll have a look next week

Read more comments on GitHub >

github_iconTop Results From Across the Web

ObjectMapper enable method is deprecated - Stack Overflow
ObjectMapper objectMapper · = JsonMapper .builder() .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) .disable(SerializationFeature.
Read more >
Deprecated List (jackson-databind 2.13.0 API) - FasterXML
Since 2.12 deprecated. ... Since 2.7, should not need to access bindings directly ... ObjectMapper.configure(MapperFeature, boolean). Since 2.13 use ...
Read more >
ObjectMapper (jackson-databind 2.14.1 API) - javadoc.io
Feature s for parser instances this object mapper creates. ObjectMapper · configure(MapperFeature f, boolean state). Deprecated. Since 2.13 use ...
Read more >
Deprecated List (jackson-databind 2.7.0 API) - Javadoc Extreme
com.fasterxml.jackson.databind.ObjectMapper._defaultPrettyPrinter. Since 2.6, do not use: will be removed in 2.7 or later.
Read more >
Deprecated List (jackson-databind 2.10.1 API)
Since 2.7.2, does not seem to be used? com.fasterxml.jackson.databind.ObjectMapper._initForReading(JsonParser) · com.fasterxml.jackson.databind.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found