You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2012/12/12 23:12:04 UTC

git commit: THRIFT-1699 Native Union#read has extra read_field_end call Patch: Kevin Radloff

Updated Branches:
  refs/heads/master 7740739b7 -> a9e33bf0f


THRIFT-1699 Native Union#read has extra read_field_end call
Patch: Kevin Radloff


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/a9e33bf0
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/a9e33bf0
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/a9e33bf0

Branch: refs/heads/master
Commit: a9e33bf0f699cd35ce2a1442a705c468b3e4ca45
Parents: 7740739
Author: Jens Geyer <je...@apache.org>
Authored: Wed Dec 12 23:11:04 2012 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Wed Dec 12 23:11:04 2012 +0100

----------------------------------------------------------------------
 lib/rb/ext/struct.c       |    3 ---
 lib/rb/spec/union_spec.rb |   14 +++++++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/a9e33bf0/lib/rb/ext/struct.c
----------------------------------------------------------------------
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index 5a9a679..8fbadbe 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -627,9 +627,6 @@ static VALUE rb_thrift_union_read(VALUE self, VALUE protocol) {
     rb_raise(rb_eRuntimeError, "too many fields in union!");
   }
 
-  // read field end
-  default_read_field_end(protocol);
-
   // read struct end
   default_read_struct_end(protocol);
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/a9e33bf0/lib/rb/spec/union_spec.rb
----------------------------------------------------------------------
diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb
index db08cab..dd84906 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -93,7 +93,7 @@ describe 'Union' do
       lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
     end
 
-    it "should serialize correctly" do
+    it "should serialize to binary correctly" do
       trans = Thrift::MemoryBufferTransport.new
       proto = Thrift::BinaryProtocol.new(trans)
 
@@ -105,6 +105,18 @@ describe 'Union' do
       other_union.should == union
     end
 
+    it "should serialize to json correctly" do
+      trans = Thrift::MemoryBufferTransport.new
+      proto = Thrift::JsonProtocol.new(trans)
+
+      union = SpecNamespace::My_union.new(:integer32, 25)
+      union.write(proto)
+
+      other_union = SpecNamespace::My_union.new(:integer32, 25)
+      other_union.read(proto)
+      other_union.should == union
+    end
+
     it "should raise when validating unset union" do
       union = SpecNamespace::My_union.new
       lambda { union.validate }.should raise_error(StandardError, "Union fields are not set.")