-
Notifications
You must be signed in to change notification settings - Fork 11
Description
In proto3, message type fields are always optional; adding the optional keyword does not change the compiled java code
i.e)
message Message {
Field field = 1;
}
message Field {
string name = 1;
}is equal to
message Message {
optional Field field = 1;
}
message Field {
string name = 1;
}However, krotoDC currently generates different code for these two cases
data class Message(
val field: Field = Field()
)data class Message(
val field: Field? = null
)Because of this, when a krotoDC message type field is not set, while message type fields with the optional keyword are "unset", fields without the keyword is set with an empty message (with all fields unset).
Strictly speaking, this contradicts the proto3 syntax's basic rule; that all message fields are optional. But it is true that this difference could be preferred for certain cases.
The best way to go would be adding an option for the krotoDC protoc plugin that when enabled, creates all message type fields as nullable. then, if this is preferred by the majority of users, we could adpot it as the default behavior