[ https://issues.apache.org/jira/browse/THRIFT-4381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer resolved THRIFT-4381. -------------------------------- Resolution: Not A Problem Assignee: Jens Geyer Fix Version/s: 0.11.0 > Wrong isset bitfield value after transmission > --------------------------------------------- > > Key: THRIFT-4381 > URL: https://issues.apache.org/jira/browse/THRIFT-4381 > Project: Thrift > Issue Type: Bug > Components: Java - Library > Affects Versions: 0.10.0 > Environment: Linux Arch / Oracle JDK v1.8.0u152 > and > Windows 7 / Oracle JDK v1.8.0u151 > Reporter: Nicolas V. > Assignee: Jens Geyer > Labels: newbie, usability > Fix For: 0.11.0 > > > The bitfield field is set to true for every field after deserialization of a > Thrift message structure. > Here is a simple test program : > {code:java} > public class BitFieldTest > { > public static void main(String[] args) throws TException > { > final CBChannel chan = new CBChannel(); > chan.setId(42L); > chan.setName("test"); > // should return true, true, false > System.out.println("id is set ? " + chan.isSetId()); > System.out.println("name is set ? " + chan.isSetName()); > System.out.println("duration max is set ? " + > chan.isSetDurationMax()); > final TProtocolFactory protoFactory = new > TCompactProtocol.Factory(); > final byte[] buf = new > TSerializer(protoFactory).serialize(chan); > System.out.println("\n---- Hexdump serialized message : ----\n" > + HexTools.toHexString(buf)); > final CBChannel chanDst = new CBChannel(); > new TDeserializer(protoFactory).deserialize(chanDst, buf); > System.out.println("---- toString() of deserialized api msg : > ----\n" + chanDst); > // should return true, true, false > System.out.println("\nid is set ? " + chanDst.isSetId()); > System.out.println("name is set ? " + chanDst.isSetName()); > System.out.println("duration max is set ? " + > chanDst.isSetDurationMax()); > } > } > {code} > The output is : > {noformat} > id is set ? true > name is set ? true > duration max is set ? false > ---- Hexdump serialized message : ---- > 00 16 54 18 04 74 65 73 74 12 26 00 16 00 16 00 16 .T..test.&...... > 10 00 16 00 16 00 16 00 00 ........ > ---- toString() of deserialized api msg : ---- > CBChannel(id:42, name:test, enabled:false, type:null, durationMin:0, > durationMax:0, inactivityAlarm:0, analogicConfiguration:0, > digitalConfiguration:0, voipConfiguration:0, r17Index:0, group:null) > id is set ? true > name is set ? true > duration max is set ? true > {noformat} > You can see that the last test for is set on the durationMax field return > true, when it sould return false. > Here is the idl file : > {code:java} > enum ChannelType > { > ANALOGIC > DIGITAL > VOIP > } > struct CBChannelGroup > { > 1: i64 id; > 2: i64 parentId; > 3: string name; > } > struct CBChannel > { > 1: i64 id; > 2: string name; > 3: bool enabled; > 4: ChannelType type; > 5: i64 durationMin; > 6: i64 durationMax; > 7: i64 inactivityAlarm; > 8: i64 analogicConfiguration; > 9: i64 digitalConfiguration; > 10: i64 voipConfiguration; > 11: i64 r17Index; > 12: CBChannelGroup group; > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)