thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4381) Wrong bitfield value after transmission
Date Thu, 09 Nov 2017 20:59:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16246504#comment-16246504
] 

Jens Geyer commented on THRIFT-4381:
------------------------------------

Actually, this might be by design. Can we see the IDL file please?





> Wrong 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.
>              Labels: newbie, usability
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message