Skip to content

JsonDeserializer getNullValue does not match NullValueProvider #5056

@pjfanning

Description

@pjfanning

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

NullValueProvider return Object
JsonDeserializer return T

https://github.com/FasterXML/jackson-databind/blob/2.19/src/main/java/com/fasterxml/jackson/databind/deser/NullValueProvider.java#L27

https://github.com/FasterXML/jackson-databind/blob/2.19/src/main/java/com/fasterxml/jackson/databind/JsonDeserializer.java#L313

Interestingly, getAbsentValue returns Object in both.

I'm hitting a real world issue in Scala. Scala 2.11 and 2.12 cannot handle the mixed typing and won't let me override getNullValue in jackson-module-scala. Scala 2.13 and Scala 3 are ok. Unfortunately, we need to support older Scala releases.

One option is to say that it might break things to chnage the signatures in Jackson 2 but could we consider changing Jackson 3 to make NullValueProvider<T> and to have getNullValue and getAbsentValue to return T?

I have a possible solution for Jackson 2 that I would suggest is a temp solution on Jackson 2 that does not get forward fit to Jackson 3. Jackson 3 only gets the NullValueProvider<T> change. In Jackson 2, we could add a JsonDeserializer method called with withNullValueProvider which returns a new JsonDeserializer instance that uses the provider from withNullValueProvider. This change is one that I'm entirely sure about.

Version Information

All recent versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    to-evaluateIssue that has been received but not yet evaluated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions