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
For some reason in 2.20.0 version deserialization of objects that contains value class with single private constructor now throws exception. I found a workaround how to fix this, but wondering if this is an issue or it was intended?
Simple example to reproduce the issue:
classValueDeserializationTest {
@Test
funtestWrapperDeserialization() {
val mapper = jacksonObjectMapper()
val wrapper:Wrapper= mapper.readValue("""{"data":"test"}""")
assertEquals("test", wrapper.data.value)
}
data classWrapper(valdata:Data)
@JvmInline
value classData private constructor(valvalue:String) {
companionobject {
funcreate(value:String): Data {
returnData(value)
}
}
}
}
This works properly on 2.19.2 version. But after upgrading to 2.20.0 I got the exception during deserialization:
member is private: com.example.unit.ValueDeserializationTest$Data.constructor-impl[Ljava.lang.Object;@834e986/invokeStatic, from class com.fasterxml.jackson.module.kotlin.InternalCommonsKt (unnamed module @517d4a0d)
This could be fixed by adding @JsonCreator + @JvmStatic annotations to companion function. But is this really the only way to fix this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For some reason in 2.20.0 version deserialization of objects that contains value class with single private constructor now throws exception. I found a workaround how to fix this, but wondering if this is an issue or it was intended?
Simple example to reproduce the issue:
This works properly on 2.19.2 version. But after upgrading to 2.20.0 I got the exception during deserialization:
This could be fixed by adding
@JsonCreator + @JvmStatic
annotations to companion function. But is this really the only way to fix this?Beta Was this translation helpful? Give feedback.
All reactions