THRIFT-1331. rb: Ruby library deserializes an empty map to nil
This patch properly detects when the metadata is omitted in Compact Protocol messages.
Patch: Armaan Sarkar
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1173300 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/compact_protocol_spec.rb b/lib/rb/spec/compact_protocol_spec.rb
index 1fa2182..a88a2ae 100644
--- a/lib/rb/spec/compact_protocol_spec.rb
+++ b/lib/rb/spec/compact_protocol_spec.rb
@@ -115,6 +115,17 @@
brcp2.should == brcp
end
+ it "should deserialize an empty map to an empty hash" do
+ struct = SingleMapTestStruct.new(:i32_map => {})
+ ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
+ bytes = ser.serialize(struct)
+
+ deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
+ struct2 = SingleMapTestStruct.new
+ deser.deserialize(struct2, bytes)
+ struct.should == struct2
+ end
+
class JankyHandler
def Janky(i32arg)
i32arg * 2