GumpacG opened a new pull request, #3540:
URL: https://github.com/apache/tinkerpop/pull/3540

   ## Summary
   
   `gremlin-go` serialized a zero `BigInteger` as a GraphBinary length of `0` 
with no value
   bytes. Java's `new BigInteger(new byte[0])` throws `NumberFormatException`, 
so a Java server
   could not read zero values sent by Go. The fix encodes zero as the canonical 
single `0x00`
   byte (length 1), matching Java's `BigInteger.toByteArray()`. `BigDecimal` 
with a zero unscaled
   value is fixed transitively (it serializes its unscaled value as a 
`BigInteger`).
   
   ## Before vs After
   
   | Value | Before | After |
   |---|---|---|
   | `BigInteger(0)` | `00 00 00 00` (Java rejects) | `00 00 00 01 00` |
   | `BigDecimal` with unscaled `0` | `...00 00 00 00` (Java rejects) | `...00 
00 00 01 00` |
   
   ### Example
   
   ```go
   // Sending a zero-valued BigInteger property to a Java Gremlin Server
   g.AddV("event").Property("count", big.NewInt(0)).Iterate()
   ```
   
   Before: the Java server fails to deserialize the request 
(`NumberFormatException: Zero length BigInteger`).
   After: zero serializes to canonical bytes and is read correctly.
   
   ## Changes
   
   - `gremlin-go/driver/graphBinary.go` - `getSignedBytesFromBigInt` returns 
`[]byte{0}` for zero.
   - `gremlin-go/driver/graphBinary_test.go` - added zero exact-bytes, zero 
round-trip, and
     zero-unscaled `BigDecimal` tests.
   
   ## Testing
   
   Added `TestGraphBinaryV1` subtests for the zero cases.
   
   Assisted-by: Kiro:claude-opus-4.8
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to