1、原始错误信息

com_google_protobuf/src/google/protobuf/wire_format_lite.cc:626
String field 'brpc.policy.RpcMeta.xxx.value' contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.

2、原因

实际代码中,将二进制数据(比如序列化后的message数据)赋值给message内的string类型的字段,触发了protobuf内部的UTF-8格式校验,校验失败,导致报错

3、解决方式

方式一(推荐):把message中被赋值的string类型,改为bytes类型;bytes类型不会做UTF-8格式校验;

方式二:增加NDEBUG宏定义,这样protobuf针对string类型,会跳过校验;

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐