Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Optional field with default is encoded even if the value is the default value #131

Open
prashantv opened this issue Mar 23, 2016 · 0 comments

Comments

@prashantv
Copy link

When an optional field with a default is read, the struct is expected to have the default value set. However, when reencoding this struct, the field should not be sent over the wire as it is the default value. In the following example, a bool field has a default value of true, and is not set in the input payload, but when the payload is deserialized and serialized again, the resulting payload contains the bool set to true.

Thrift struct:

struct BoolTest {
  1: optional bool b = true;
  2: optional string s = "true";
}

Doing a roundtrip of binary -> struct -> binary modifies the following payload:

TStruct({2: TBinary([])})

to the following:

TStruct({1: TBool(true), 2: TBinary([])})

The binary for the input payload is:

> hexdump node_bool_encode.bin
0000000 0b 00 02 00 00 00 00 00
0000008
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant