Reputation: 1703
I'm working with some protocol buffers (java) that have extensions. I'm seemingly able to parse the serialized protocol buffers ok (no errors anyway), but for debugging purposes (yet another issue), I'm printing them out to a log.
I'm getting these types of things scattered around the log:
data_config {
format: FORMAT_DELIMITED
1024: "\022\001\n"
}
And here's the message definition:
message DataConfig {
optional DataFormat format = 1;
extensions 1024 to max;
option (dwhio.data.message_reflection_config) = { reflect_extensions: true };
}
My question is 'Is the debug string in the log with '1024' correct (expected) or indicative of a class loading or other problem?'
I haven't figured out a way to print to a string involving a registry, simply 'merge', so I'm assuming that's not necessary?
Upvotes: 1
Views: 502
Reputation: 45181
The problem is probably that you did not provide an ExtensionRegistry
when you parsed the message from binary. So, the extension was treated as an unknown field. When you later print the message, the extension is still unknown, so is printed as you see. The solution is to provide the registry at parse time, e.g. DataConfig.parseFrom(bytes, registry)
.
Upvotes: 1