Can Java Protocol Buffers ever return null in a getter from a repeating field?

Say you have a repeating box.

message Foo { optional int32 val = 1; } message Bar { repeated Foo foo = 1; } 

This will create a method

 List<Foo> getFooList() 

Are there any circumstances where getFooList will return null? Or will it already return the list, even if it is empty?

+6
source share
1 answer

No, there is no case when it returns null . In fact, none of the field handlers in the Java protobuf generated classes ever returned null ; they always return the default value if the field is missing. Similarly, setters do not allow null .

+7
source

All Articles