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.
I searched in the issues of databind and other modules used and found nothing similar.
I have confirmed that the problem only occurs when using Kotlin.
Describe the bug
When trying to deserialize a CSV into a target class that contains a field that is a value class and
the ObjectMapper has a CsvSchema that has column reordering enabled, Jackson will produce the following exception, seemingly ignoring the @JsonProperty annotations:
Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "BAR_HEADER" (class net.marvk.FooWithValueClass), not marked as ignorable (2 known properties: "bar", "baz"])
at [Source: (StringReader); line: 2, column: 41] (through reference chain: net.marvk.FooWithValueClass["BAR_HEADER"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1153)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2241)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1793)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperties(BeanDeserializerBase.java:1743)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:546)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1493)
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.MappingIterator.nextValue(MappingIterator.java:283)
at com.fasterxml.jackson.databind.MappingIterator.readAll(MappingIterator.java:323)
at com.fasterxml.jackson.databind.MappingIterator.readAll(MappingIterator.java:309)
at net.marvk.MainKt.main(Main.kt:20)
at net.marvk.MainKt.main(Main.kt)
This issue does not exist for data classes or if column reordering is disabled.
If possible, it'd be great to have Java-only reproduction -- if so, could transfer to jackson-dataformats-text where this belong (but can't if there's Kotlin dependency).
@cowtowncoder Well, I can only reproduce it with Kotlin Value Classes, so I'm not sure how I would reproduce it in Java 😅 As far as I know, Java doesn't have a similar concept (yet?).
I was just hoping to confirm whether this is due to Kotlin Value Class specific details (in which case it might not be CSV-specific, fwtw), or not (in which case it is CSV specific).
In former case issue could remain here (if not CSV specific); in latter case moving to jackson-dataformats-text.
But if both CSV and Kotlin aspects matter, probably needs to move to jackson-integration-tests repo.
Search before asking
Describe the bug
When trying to deserialize a CSV into a target class that contains a field that is a
value class
andthe
ObjectMapper
has aCsvSchema
that has column reordering enabled, Jackson will produce the following exception, seemingly ignoring the@JsonProperty
annotations:This issue does not exist for data classes or if column reordering is disabled.
data class
value class
false
true
Related to #768.
To Reproduce
Please see the cloneable, runnable MCVE here.
The MCVE tests demonstrate that data classes work whether column reordering is enabled or not, and value classes work with column reordering disabled.
Main.kt
Test.kt
Expected behavior
Jackson deserializes the CSV without issues just like with data class fields or with column reordering disabled.
Versions
Kotlin: 1.9.23
Jackson-module-kotlin: 2.17.1
Jackson-databind: 2.17.1
Additional context
No response
The text was updated successfully, but these errors were encountered: