Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4381

Wrong isset bitfield value after transmission

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 0.10.0
    • 0.11.0
    • Java - Library
    • Linux Arch / Oracle JDK v1.8.0u152
      and
      Windows 7 / Oracle JDK v1.8.0u151

    Description

      The bitfield field is set to true for every field after deserialization of a Thrift message structure.

      Here is a simple test program :

      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());
      	}
      }
      

      The output is :

      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
      

      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 :

      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;
      }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jensg Jens Geyer
            iXo Nicolas V.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment