Protobuf error:Protocol message tag had invalid wire type

前端 未结 2 1968
遥遥无期
遥遥无期 2021-01-02 01:28

I am having the following error when trying to read the message in java

Exception in thread \"main\" com.google.protobuf.InvalidProtocolBufferException: Prot         


        
2条回答
  •  长情又很酷
    2021-01-02 02:07

    When I see users report this type of message, it almost always means they've corrupted the file. Starting from a .txt is a worrying sign, as protocol buffers is a binary format that cannot be represented in a text encoding (unless you count base-64 etc).

    Another common cause of this is over-writing a file with less data and not trimming the excess. Since protocol buffers includes (for the root message) neither a length prefix nor a terminator, any excess data (essentially garbage now) from previous file contents will be processed. This is a bad thing; you must always trim your outputs when over-writing.

提交回复
热议问题