well. `null` is not supported with protobuf. that ...
# serialization
t
well.
null
is not supported with protobuf. that is a HUGE drawback
s
Protobuf originally does not have concept of null, only presence and absence of value which is hard to map unambiguously on Kotlin's default values/default nullable values/nullable values without default/...
t
yes found the bug report for this problem. i''l have a look what i can do 🙂
is it only the nullable types with default values that cause the problems? or default values themselves?
s
There are several problems there. What you should deserialize into
val x: Int? = 42
if
x
is missing? Even non-nullable
val x: Int = 42
can cause problems because protobuf specs clearly says that "absence of value should be treated as 0 for primitives and - huh - 'field is not set. Its exact value is language-dependent' for non-primitive types".
Java's protobuf implementation uses
null
as 'not set', but we can't afford such luxury in Kotlin
t
well i guess there are more problems here? at least those to seem to be easily solvable at first glane 🤔
in the first case i'd guess if
x
is missing it was explicitly set to
null
in the second case the serialized form would simply missmatch
what i couldn't fin out yet: is there anything i can do?