This is exactly correct. You should do two things:
1. Set this field on the sending side, but you mentioned that you are
already doing this.
2. Verify that the bytes you are reading in on one side match the
bytes being sent. I usually get this error when there is some sort of
message handling error. For example, if you pass protobuf an empty
array, you'll get this error message. You should write out the bytes
that you are writing, and the bytes that you are reading and verify
that they match. Also verify that the size you are passing in matches.
There is a difference between an unset field with a default value of
"" and a set field with a value of "". The .hasProperty() method will
return true for the set field, and false for the unset field. Thus,
these messages are serialized differently.
Hope this helps,
Evan
--
Evan Jones
http://evanjones.ca/
From what I can see the issue is as follows:
As the stringProperty value is the same as the default (an empty
string) it is not sent over the wire.
If you _set_ the value, not matter its content (yes, even if it
happens to be the default value), it is sent over the wire. Always.
How would you otherwise be able to distinguish between a not-set value
and the default value ?
The default values and its behaviors only apply to fields that are not set.
Almost certainly, you don't receive the data you think you sent. The
way to debug your problem is:
- actually make sure, that the value is set on the sending side
(check if has_property() returns true)
- serialize the value and make sure that on the receiving side you
actually get the same bytes back (print it, print its length, create a
hash from it and print that - whatever you can do to debug that). In
C/C++ it is a usual mistake to treat the binary data as \0 delimited
string, hence Kenton's suspicion.
(Note, that the Google implementation provides C++, Java and Python
but does not come with a C# version, so you're probably using one of
the 3rd party implementations.)
-h
> --
> You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
> To post to this group, send email to prot...@googlegroups.com.
> To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
>
>
The producers of the message are actually C# and not C++ as I first
mentioned (I only deal with the Java implementation). The scenario
however, is the same.
@Kenton, I thought default values were never sent over the wire.
According to the 'Updating A Message Type' section of the language
guide ..."Changing a default value is generally OK, as long as you
remember that default values are never sent over the wire...."
Are you saying this is not the case?