Oops, sorry, I was plain wrong. 
It turns out the code was setting the nonce parameter to null.
Anyway, maybe it should be necessary to change the TextFormat to better
deal with null fields?

On Fri, 2009-08-07 at 12:07 +0200, Brice Figureau wrote:
> Hi,
> I have the following message, under Protobuf 2.0.3:
> message Message {
>   required string name = 1;
>   optional string nonce = 2;
> }
> When I call toString() on this message it throws a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
>       at com.google.protobuf.ByteString.copyFromUtf8(Unknown Source)
>       at com.google.protobuf.TextFormat.escapeText(Unknown Source)
>       at com.google.protobuf.TextFormat.printFieldValue(Unknown Source)
>       at com.google.protobuf.TextFormat.printSingleField(Unknown Source)
>       at com.google.protobuf.TextFormat.printField(Unknown Source)
>       at com.google.protobuf.TextFormat.print(Unknown Source)
>       at com.google.protobuf.TextFormat.print(Unknown Source)
>       at com.google.protobuf.TextFormat.printToString(Unknown Source)
>       at com.google.protobuf.AbstractMessage.toString(Unknown Source)
> Which means it is impossible to have a null default value in a message,
> we have to always have a default value (which is sometimes not
> possible).
> Is that the expected behaviour?

Brice Figureau
My Blog: http://www.masterzen.fr/

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to