Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staged builder breaks jackson deserialization of nullable fields #1407

Closed
SimY4 opened this issue Oct 7, 2022 · 1 comment
Closed

Staged builder breaks jackson deserialization of nullable fields #1407

SimY4 opened this issue Oct 7, 2022 · 1 comment

Comments

@SimY4
Copy link
Contributor

SimY4 commented Oct 7, 2022

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.

@elucash
Copy link
Member

elucash commented Oct 15, 2022

Thank you for reporting this. It's hard to dig every feature combination, especially with quite complex Jackson mapping. Here I would ask for help, If staged builder is involved then how it exactly affects Jackson so it doesn't work? One can, for example, take the generated code and out it into a source folder, remove @Value.Immutable annotation and try to fiddle / debug the code to find out what causes the problem.

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

No branches or pull requests

2 participants