Skip to content

Staged builder breaks jackson deserialization of nullable fields #1407

Description

@SimY4

Consider an entity definition:

@Value.Immutable
@Value.Style(stagedBuilder = true)
@JsonDeserialize(as = ImmutableEntity.class)
public interface Entity {
  @Value.Default
  default String getNullableDefault() {
    return "default";
  }
}

and a JSON string: {"nullableDefault":null}

This would fail jackson deserialisation with:

Can not construct instance of org.immutables.fixture.jackson.ImmutableEntity, problem: nullableDefault
 at [Source: {"nullableDefault":null}; line: 1, column: 40]
	at org.immutables.fixture.jackson.ObjectMappedTest.jsonNullableWithDefault(ObjectMappedTest.java:252)
Caused by: java.lang.NullPointerException: nullableDefault
	at org.immutables.fixture.jackson.ObjectMappedTest.jsonNullableWithDefault(ObjectMappedTest.java:252)

If you remove @Value.Style serialization works as expected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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