For a message like this
messages Orders {
repeated Order payloads = 1;
}
message Order {
...
}
Actually this can be any message with size above ~2GB.
With a toByte
call, it would result in CodeOutputStream was writing to a flat byte array and ran out of space
.
sample code:
Any.pack(orders).toByteArray();
This is actually an issue with the size variable being an int
. Hence, the message.getSerializedSize()
would give a wrong value (smaller than its real size). Hence, when the CodeOutputStream
was trying to write the bytes, eventually it write more than the limit
which is from message.getSerializedSize()
.
https://github.com/protocolbuffers/protobuf/issues/10033
