Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.9.3, 0.10.0
-
Ubuntu 15.10
Description
Go code for unions generated by Thrift 0.9.3 fails to consider map/set/list fields of a union when enforcing that the number of fields set is 1. For example:
union Foo{ 1: map<bool,bool> u1 2: set<bool> u2, 3: list<bool> u3, 4: bool u4, }
Produces Go code:
type Foo struct { U1 map[bool]bool `thrift:"u1,1" json:"u1,omitempty"` U2 map[bool]bool `thrift:"u2,2" json:"u2,omitempty"` U3 []bool `thrift:"u3,3" json:"u3,omitempty"` U4 *bool `thrift:"u4,4" json:"u4,omitempty"` } ... func (p *Foo) CountSetFieldsFoo() int { count := 0 if p.IsSetU4() { count++ } return count } ... func (p *Foo) Write(oprot thrift.TProtocol) error { if c := p.CountSetFieldsFoo(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } ...
Due to this bug, Thrift will complain that a union with only the fields u1, u2, or u3 set has no fields set. And it will allow all four fields to be set.
Attachments
Issue Links
- links to