--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
As a work-around, you can implement a simple protoc plugin that will generate additional null-friendly methods into the classes already created by the Java codegen built into protoc.That's actually what we've done at Square. As you point out, the null-unfriendliness is particularly burdensome with builders, for cases where you want to use method-chaining but also conditionally set or clear a field.Our generated messages include getOrNull*() accessor fields (so they return null if unset instead of the field's default value) and the builders have setOrClear*() setter methods (that clear the field when null is passed in).
----Josh HumphriesManager, Shared Systems | Platform EngineeringAtlanta, GA | 678-400-4867Square (www.squareup.com)
On Mon, Jun 8, 2015 at 4:04 AM, Andreas V <andre...@gmail.com> wrote:
I know its an old thread but i use protobuf3 with Java and it has the same NPE behavior with .set(null-reference). Is their any chance to change this? an option to generating java classes would be nice. It is absolutly annoying to null-check on every .set method. This will lead to more errors in code and expand it inadequate due to chained-setters are not possible. :(
Am Mittwoch, 29. Mai 2013 23:50:59 UTC+2 schrieb prot...@googlecode.com:
Comment #6 on issue 491 by xiaof...@google.com: Optional field throws
NullPointerException when not set values.
http://code.google.com/p/protobuf/issues/detail?id=491
We don't have the intention to change to the current behavior. Passing null
is likely to be a programming error. Allowing it might do more harm than
good.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prot...@googlegroups.com.