You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched in the issues and found nothing similar.
Describe the bug
Hello,
While updating to spring boot 3.4.x I faced an issue related to the upgrade of jackson dependencies from 2.17.3 to 2.18.2
Deserialization is not working anymore for a class with 2 constructor, one with @JsonCreator annotation.
It fails with this exception:
Instantiation of [simple type, class User] value failed for JSON property fullName due to missing (therefore NULL) value for creator parameter fullName which is a non-nullable type
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 6, column: 13] (through reference chain: User["fullName"])
com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class User] value failed for JSON property fullName due to missing (therefore NULL) value for creator parameter fullName which is a non-nullable type
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 6, column: 13] (through reference chain: User["fullName"])
at com.fasterxml.jackson.module.kotlin.KotlinValueInstantiator.createFromObjectWith(KotlinValueInstantiator.kt:97)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:214)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:541)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1497)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:348)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4931)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3868)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3851)
at UserDeserializationTest.test user deserialization(UserDeserializationTest.kt:25)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
It seems it take the wrong constructor, I also try with @JsonIgnore and @JsonCreator(mode=DISABLED) on the first constructor but it didn't help.
Any idea on how to solve this issue?
It does seem like a really odd example. The json does not relate to the constructors. Can't you add another constructor that takes "age", "firstName", "lastName"?
Search before asking
Describe the bug
Hello,
While updating to spring boot 3.4.x I faced an issue related to the upgrade of jackson dependencies from 2.17.3 to 2.18.2
Deserialization is not working anymore for a class with 2 constructor, one with @JsonCreator annotation.
It fails with this exception:
It seems it take the wrong constructor, I also try with
@JsonIgnore
and@JsonCreator(mode=DISABLED)
on the first constructor but it didn't help.Any idea on how to solve this issue?
Version Information
2.18.2,2.18.3
Reproduction
Project with failing test can be found on this repo https://github.com/fabienfleureau/jackson-deserialization-issue/
I have defined this class:
and the json to deserialize looks like this:
Expected behavior
I expected to have a user deserialized having age set to 25, firstName set to Jane and lastName set to Doe
Additional context
No response
The text was updated successfully, but these errors were encountered: