Hey everyone. I’m migrating from `0.4.0` to `0.8.1...
# kotlinx-rpc
y
Hey everyone. I’m migrating from
0.4.0
to
0.8.1
and it looks like new version doesn’t serialize default arguments anymore, I’m just getting NPE:
Copy code
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null
...
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:259)
	at kotlinx.serialization.encoding.AbstractEncoder.encodeSerializableElement(AbstractEncoder.kt:80)
	at kotlinx.rpc.krpc.internal.CallableParametersSerializer.serialize(SerializationUtils.kt:127)
	at kotlinx.rpc.krpc.internal.CallableParametersSerializer.serialize(SerializationUtils.kt:100)
	at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:259)
	at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:99)
Could you help to understand if this is regression or I did something wrong?
1
wait, it looks like the problem a bit different, the field is:
Copy code
createdAtFrom: Instant? = null,
but it calls our custom
KSerializer<Instant>
with null, it doesn’t handle nullability properly
@Alexander Sysoev could you take a look please?
shouldn’t here:
Copy code
override fun serialize(
        encoder: Encoder,
        value: Array<Any?>,
    ) {
        encoder.encodeStructure(descriptor) {
            for (i in callable.parameters.indices) {
                encodeSerializableElement(descriptor, i, callableSerializers[i], value[i])
            }
        }
    }
be
encodeNullableSerializableElement
?
probably no, as I see
callableSerializers
actually have nullable serializers for common types like String
aha, here:
Copy code
internal fun SerializersModule.buildContextualInternal(type: KType): KSerializer<Any?>? {
    val result = getContextual(
        kClass = type.rpcInternalKClass(),
        typeArgumentsSerializers = type.arguments.mapIndexed { i, typeArgument ->
            val typeArg = typeArgument.type
                ?: error("Unexpected star projection type at index $i in type arguments list of '$type'")

            buildContextualInternal(typeArg) ?: serializer(typeArg)
        }
    )

    @Suppress("UNCHECKED_CAST")
    return result as? KSerializer<Any?>
}
probably we need to mark KSerializer nullable if KType is nullable
@Alexander Sysoev when you have time: https://github.com/Kotlin/kotlinx-rpc/pull/392 (it’s migration blocker for us)
a
@Yakiv Yereskovskyi thanks for the PR will take a look on Monday!
y
@Alexander Sysoev do you have nighty builds or something to get new changes ASAP?
a
I can make one, but probably it will be just 2-3 hours earlier then the official release
y
ok, don’t bother then, we can wait 2-3 hours more
thanks
a
I'll try to do the release tomorrow noon
🙏 1
@Yakiv Yereskovskyi Had problems with Maven Central, but it out now
y
np, thanks