Author: bryanduxbury
Date: Tue Mar 31 23:48:36 2009
New Revision: 760735

URL: http://svn.apache.org/viewvc?rev=760735&view=rev
Log:
THRIFT-415. rb: BinaryProtocolAccelerated does not behave properly when strict 
reads are turned off

This patch adds the appropriate test for the behavior and fixes the 
thrift_native project to do the right thing. 


Modified:
    incubator/thrift/trunk/lib/rb/ext/binary_protocol_accelerated.c
    incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec_shared.rb

Modified: incubator/thrift/trunk/lib/rb/ext/binary_protocol_accelerated.c
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/ext/binary_protocol_accelerated.c?rev=760735&r1=760734&r2=760735&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/ext/binary_protocol_accelerated.c (original)
+++ incubator/thrift/trunk/lib/rb/ext/binary_protocol_accelerated.c Tue Mar 31 
23:48:36 2009
@@ -300,7 +300,7 @@
       rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), 
rb_str_new2("No version identifier, old protocol client?")));
     }
     name = READ(self, version);
-    type = rb_thrift_binary_proto_read_byte(self);
+    type = read_byte_direct(self);
     seqid = rb_thrift_binary_proto_read_i32(self);
   }
   

Modified: incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec_shared.rb
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec_shared.rb?rev=760735&r1=760734&r2=760735&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec_shared.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec_shared.rb Tue Mar 31 
23:48:36 2009
@@ -208,6 +208,12 @@
     @prot.read_message_begin().should == ['testMessage', 
Thrift::MessageTypes::CALL, 17]
   end
   
+  it "should read the message header without version when writes are not 
strict" do
+    @prot = protocol_class.new(@trans, false, true) # no strict write
+    @trans.write("\000\000\000\vtestMessage\001\000\000\000\021")
+    @prot.read_message_begin().should == ['testMessage', 
Thrift::MessageTypes::CALL, 17]
+  end
+
   # message footer is a noop
   
   it "should read a field header" do


Reply via email to