Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Duplicate
-
0.7
-
None
-
Windows 0.7 thrift compiler (pre built)
http://www.apache.org/dyn/closer.cgi?path=/thrift/0.7.0/thrift-0.7.0.exeThrift 0.7 compiled on Ubuntu shows same symptoms
Description
I compiled cassandra.thrift using "thrift --gen js:node cassandra.thrift".
When I use this code this results in the following error from cassandra / thrift:
{ name: 'TApplicationException', type: 7, message: 'Required field \'reversed\' was not found in serialized data! Struct : SliceRange(start:null, finish:null, reversed:false, count:100)' }
If I look in the generated code, I find
SliceRange.prototype.write = function(output) { output.writeStructBegin('SliceRange'); if (this.start) { output.writeFieldBegin('start', Thrift.Type.STRING, 1); output.writeString(this.start); output.writeFieldEnd(); } if (this.finish) { output.writeFieldBegin('finish', Thrift.Type.STRING, 2); output.writeString(this.finish); output.writeFieldEnd(); } if (this.reversed) { output.writeFieldBegin('reversed', Thrift.Type.BOOL, 3); output.writeBool(this.reversed); output.writeFieldEnd(); } if (this.count) { output.writeFieldBegin('count', Thrift.Type.I32, 4); output.writeI32(this.count); output.writeFieldEnd(); } output.writeFieldStop(); output.writeStructEnd(); return; };
this.reversed is false and subsequently does not get sent
If I look at the compiled version that was generated by 0.6.1 I see:
SliceRange.prototype.write = function(output){ output.writeStructBegin('SliceRange') if (null != this.start) { output.writeFieldBegin('start', Thrift.Type.STRING, 1) output.writeString(this.start) output.writeFieldEnd() } if (null != this.finish) { output.writeFieldBegin('finish', Thrift.Type.STRING, 2) output.writeString(this.finish) output.writeFieldEnd() } if (null != this.reversed) { output.writeFieldBegin('reversed', Thrift.Type.BOOL, 3) output.writeBool(this.reversed) output.writeFieldEnd() } if (null != this.count) { output.writeFieldBegin('count', Thrift.Type.I32, 4) output.writeI32(this.count) output.writeFieldEnd() } output.writeFieldStop() output.writeStructEnd() return }
null is also not be completely correct, the solution would be:
... if (undefined !== this.reversed) ...
Unless this change was intentional and breaks things because cassandra is perhaps using an old thrift version?
Attachments
Issue Links
- is duplicated by
-
THRIFT-1499 Generated javascript code doesn't properly write optional falsy values
- Closed