Developers guide says:

"Messages created by your new code can be parsed by your old code: old 
binaries simply ignore the new field when parsing. However, the unknown 
fields are not discarded, and if the message is later serialized, the 
unknown fields are serialized along with it – so if the message is passed 
on to new code, the new fields are still available."

I'm interested in exactly this scenario - old client gets a message from 
the new client, changes something, and sends it back.

I gave it a try, and what I saw is that new proto fields are stored in 
unknownFields. But when I do build(), these fields are discarded.

So when the message is serialized, the new fields are gone. Am I doing it 
wrong ?

I found that I could simply serialize the message, and then separately 
serialize the unknownFieldSet, so they are concatenated to the message. 

But this doesn't feel like the right way. Is it ?

I also found this: https://github.com/bivas/protobuf-java-format/pull/26, 
but last activity was a year ago.

What's the right way of having the old client serialize a message including 
fields it doesn't understand ?



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+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to