Hello! `com.google.protobuf.kotlin.Struct` uses Do...
# kotlinx-rpc
s
Hello!
com.google.protobuf.kotlin.Struct
uses Double for numeric values (
Kind.NumberValue(public val value: Double)
), so we face a precision loss when converting to Long for example. Consider this case where the client is sending a
mapOf("key" to Long.MAX_VALUE - 1)
, the server when parsing this to
Map<String, Long>
it has to read the double value of
NumberValue
and call
.toLong()
which will end up with a different value
Copy code
[Client] message={key=9223372036854775806}
[Server] message={key=9223372036854775807}
Is this a known issue? Any ideas how to overcome this? The full example can be found at https://github.com/salah3x/kotlin-rpc-struct-bug
a
Hi! This is protobuf's own declaration from WKT https://github.com/protocolbuffers/protobuf/blob/517be42cfe43c9e2c69f5ee40e437a9d8cbd3f99/src/google/protobuf/struct.proto#L77 Work around is to use your own Struct type I'd say
🙏 1