Re: TextFormat and optional fields.
Protobuf 2.1.0 throws NPE when you try to set a field to null. So, this has been long fixed. On Fri, Aug 7, 2009 at 4:30 AM, Brice Figureau > wrote: > > Hi, > > 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 protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: TextFormat and optional fields.
Hi, 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 protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
TextFormat and optional fields.
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? /me adding defaults everywhere :-) Thanks, -- 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 protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---