-
Notifications
You must be signed in to change notification settings - Fork 175
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
Improve serialization support for value class #659
Conversation
Add ValueClassBoxConverter cache This cache has been confirmed on kogera to have the effect of speeding up initialization. from https://github.com/ProjectMapK/jackson-module-kogera/blob/da6d05cb36e5584b991e092a4eabd050909a1677/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt
60ed48c
to
9093927
Compare
@@ -59,12 +58,12 @@ class GitHub524 { | |||
|
|||
class SerializeByAnnotation(@get:JsonSerialize(using = Serializer::class) val foo: HasSerializer = HasSerializer(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, the Serializer
did not work because of a mismatch in the return type from the getter
.
With the change in this PR to use Converter
, the types will now match and the Serializer
will work.
// Decompile result for this getter, the return type is not HasSerializer due to unboxing
@JsonSerialize(using = Serializer.class)
@NotNull
public final Integer getFoo-Q01F06U() {
// Determine if the unbox result of value class is nullAable | ||
// @see findNullSerializer | ||
private fun KClass<*>.requireRebox(): Boolean = | ||
this.memberProperties.first { it.javaField != null }.returnType.isMarkedNullable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will eliminate the bug described in the following comment.
#618 (comment)
@cowtowncoder Personally, I think it is safe to merge the existing |
You can decide whether to merge it in 2.15 (there is still time), or wait until 2.15.0 is out and merge into 2.16 (once branch exists). I don't have a strong opinion. I'll cc @dinomite nor @viartemev just in case they might have some feedback; but in absence of other reviewers you are free to decide on how to proceed, basically. |
OK, merge immediately. |
JsonSerializer
is enabled when the value is an Object type with non-null value and the property definition is nullable. #618 is fixed.value class
isnull
, it is not excluded from serialization #625 is partially fixed.value class
as argument does not work #651.