Skip to content

configOverrides(boolean.class) silently ignored, wheres .configOverride(Boolean.class) works for both primitives and boxed boolean values #3080

@asaf-romano

Description

@asaf-romano

Using version 2.12:

mapper.configOverride(Boolean.class).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER));

This works as expected. Boxed Boolean values are serialized as 1/0. Moreover, it also works for primitive booleans.

However,

mapper.configOverride(boolean.class).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER));

seems to do nothing, for either types.

I find this behavior quite surprising. I think it's reasonable to assume any of the following:

  1. boolean implies Boolean symmetrically
  2. boolean implies Boolean, but not the other way around (mirroring the current behavior)
  3. (1) + ability to override the format for the boxed type (to be clear, I've no use case for that)
  4. An error to be thrown by configOverride.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions