If this is true, all the fields in the data model are platform types, which means no null safety unless you explicitly cast each one of them to a nullable type -- which is pretty bad for null safety.
If Java is what's generated it would be nice if it at least marked everything nullable with an annotation (https://kotlinlang.org/docs/java-interop.html#nullability-annotations) just so Kotlin has some idea what to do.
Ideally it would be nice if it actually generated Kotlin instead of Java; maybe it does but I'm not seeing it?
m
Marc Plano-Lesay
07/27/2022, 9:49 PM
Isn't protobuf-java already guaranteeing that it'll never return null anywhere?
d
davec
07/27/2022, 9:50 PM
Not that I'm aware of. My understanding is that everything in gRPC can be nullable all the time by design (so you can change the API).
I'm not 100% sure but close that a field that's not set will return a default instance, not null
j
Júlio Santos
07/30/2022, 10:20 AM
Hi @davec, how are you?
I have seen your interaction here on the channel about gRPC, do you have any projects available?
I will start studying about this subject
j
Johann Pardanaud
08/01/2022, 12:28 PM
I can confirm: protobuf-java garanties everything is not null, when you access an undefined field you will get a default instance
So no worries with Kotlin, yes you are using platform types, but you will never get any null values