The post records the issue I met when using protobuf uint64 and Java Long.
When we define some protobuf message with ab “uint64”(unsigned int64) type field in it, and decode the corresponding binary payload to a Java object, the uint64 field in protobuf format will be mapped to a Long type Java field.
An potential issue may happen in such case: if the uint64 number is bigger than “Long.MAX_VALUE“, it will be converted to a negative Java Long value. For example:
1 | # Note: 9223372036854775807 is Long.MAX_VALUE: |
This caused confusions and issues. To fix it, use the code below to convert:
1 | String id = "14001908927091871061"; |