**Description** - We have observed intermittent issues when calling `NativeFromBinary()` on union types. - After some investigations, we identified that a shared resource `cr.allowedTypes` was sorted and mutated, therefore causing the issue. **Repro steps:** - Given a codec created as NewCodecForStandardJSONFull(`[ "null", "long"]`) - When calling first `codec.NativeFromTextual()` with a long (e.g. `codec.NativeFromTextual([]byte("1"))`) - And calling second `codec.BinaryFromTextual()` with a long value (e.g. `codec.NativeFromBinary([]byte{0x02, 0x06})`) - Expected: native object is `map[string]interface{}["long", 3]` - Actual: native object is `map[string]interface{}["null", 3]
Description
NativeFromBinary()on union types.cr.allowedTypeswas sorted and mutated, therefore causing the issue.Repro steps:
Given a codec created as NewCodecForStandardJSONFull(
[ "null", "long"])codec.NativeFromTextual()with a long (e.g.codec.NativeFromTextual([]byte("1")))codec.BinaryFromTextual()with a long value (e.g.codec.NativeFromBinary([]byte{0x02, 0x06}))Expected:
native object is
map[string]interface{}["long", 3]Actual:
native object is `map[string]interface{}["null", 3]