Protobuf: strange transformation int64 to Long

479 Views Asked by At

The protobuf-file has the following declaration of method:

message GetRequest {
   int64 client_id = 1;
   google.protobuf.StringValue name = 2;
 }

It generate:

final case class GetRequest(
    clientId: _root_.scala.Long = 0L,
    name: scala.Option[_root_.scala.Predef.String] = None
)

I invoke method with different values of clientId and observe the behavior by Idea-debug.

As a result:

  • Some values of clientId, for example 816645943620556288, passed successfully.

  • But some another passed with strange transformation. For example, for 12550491997690948864 last digits transforms to 912 (from 864). So in fact method receive non correct argument: 12550491997690948912. One more example 1267049198769094768 to 1267049198769094656

I suspect, some bytes shuffled or missed at the tail of passed value (while int64 transformed to Long).

But I'm not sure.

0

There are 0 best solutions below