[
https://issues.apache.org/jira/browse/TINKERPOP-3277?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Cole Greer closed TINKERPOP-3277.
---------------------------------
Fix Version/s: 3.7.7
3.8.2
Assignee: Cole Greer
Resolution: Fixed
> gremlin-go can't serialize zero in bigdecimal/biginteger
> --------------------------------------------------------
>
> Key: TINKERPOP-3277
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3277
> Project: TinkerPop
> Issue Type: Bug
> Components: go
> Affects Versions: 3.7.6, 3.8.1
> Reporter: Ken Hu
> Assignee: Cole Greer
> Priority: Minor
> Fix For: 3.7.7, 3.8.2
>
>
> Caveat: I haven't fully verified this, just something AI told me when I was
> writing the "model" tests for gremlin-go. Just putting here so it can be
> checked later.
> Gremlin-Go serializes zero BigInteger as a GraphBinary length of 0 with no
> bytes. Java expects a valid two’s-complement BigInteger byte array, where
> zero is encoded as length 1 with byte 0x00. When Java reads Go’s zero-length
> form, new BigInteger(new byte[0]) throws NumberFormatException, so Java
> servers cannot read zero BigInteger values sent by Go.
> The same affects BigDecimal when its unscaled value is zero, because that
> unscaled value is serialized as a BigInteger.
> {code:java}
> func TestZeroBigIntegerGraphBinaryV1Bytes(t *testing.T) {
> var buffer bytes.Buffer
> got, err := bigIntWriter(*big.NewInt(0), &buffer, nil)
> if err != nil {
> t.Fatal(err)
> }
> want := []byte{0x00, 0x00, 0x00, 0x01, 0x00}
> if !bytes.Equal(got, want) {
> t.Fatalf("zero BigInteger bytes = % x, want % x", got, want)
> }
> }
> Current output:
> 00 00 00 00
> Expected output:
> 00 00 00 01 00
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)