John, that is awesome.  Do you have examples of how you did that? AND can 
it be done under the covers of doing gRPC which we are looking into?

Also, since protobuf supports json now, I am wondering because of the above 
issue if it supports "age":null vs "age":0 vs. non existent age in the 
json?  ie. this post 
https://groups.google.com/forum/#!topic/protobuf/d51mjUf_w7g

Especially since I just coded up a grpc-json plugin that we are going to 
start testing out/(and perhaps using) here 
https://github.com/deanhiller/webpieces/tree/master/webserver-plugins/plugin-grpc-json
We are about to add the binary one as well.

thanks,
Dean

On Tuesday, June 9, 2015 at 11:07:13 AM UTC-6, Josh Humphries wrote:
>
> 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 Humphries*
> Manager, Shared Systems  |  Platform Engineering
> Atlanta, GA  |  678-400-4867
> *Square* (www.squareup.com)
>
> On Mon, Jun 8, 2015 at 4:04 AM, Andreas V <[email protected] 
> <javascript:>> 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 [email protected]:
>>>
>>>
>>> Comment #6 on issue 491 by [email protected]: 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/2c7efb10-e319-4944-9316-e94bca5ad9bd%40googlegroups.com.

Reply via email to