[ https://issues.apache.org/jira/browse/THRIFT-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15174446#comment-15174446 ]
Tom Deering edited comment on THRIFT-3703 at 3/1/16 9:33 PM: ------------------------------------------------------------- Seems to affect union fields of type map, set, and list. So not just Map was (Author: tdeering): Seems to affect union fields of type map, set, and list. > Unions Field Count Does Not Consider Map/Set/List Fields > -------------------------------------------------------- > > Key: THRIFT-3703 > URL: https://issues.apache.org/jira/browse/THRIFT-3703 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.9.3 > Environment: Ubuntu 15.10 > Reporter: Tom Deering > Labels: golang, thrift, union > > Go code for unions generated by Thrift 0.9.3 fails to consider map fields of > a union when enforcing that the number of fields set is 1. For example: > {code} > union Foo{ > 1: map<bool, bool> u1, > 2: bool u2, > } > {code} > Produces Go code: > {code} > type Foo struct { > U1 map[bool]bool `thrift:"u1,1" json:"u1,omitempty"` > U2 *bool `thrift:"u2,2" json:"u2,omitempty"` > } > func (p *Foo) CountSetFieldsFoo() int { > count := 0 > if p.IsSetU2() { > 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) > } > ... > {code} > Due to this bug, Thrift will complain that a union with only field u1 set has > no fields set. -- This message was sent by Atlassian JIRA (v6.3.4#6332)