If this is true, all the fields in the data model ...
# grpc
d
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
Isn't protobuf-java already guaranteeing that it'll never return null anywhere?
d
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).
at least in proto3
m
I'm not 100% sure but close that a field that's not set will return a default instance, not null
j
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
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