From ac002d32a787ae1245fd27f43ad7de185845e32c Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Tue, 31 Mar 2009 23:48:36 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@760735 13f79535-47bb-0310-9956-ffa450edef68 --- lib/rb/ext/binary_protocol_accelerated.c | 2 +- lib/rb/spec/binaryprotocol_spec_shared.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rb/ext/binary_protocol_accelerated.c b/lib/rb/ext/binary_protocol_accelerated.c index e7ea39e0..751281e2 100644 --- a/lib/rb/ext/binary_protocol_accelerated.c +++ b/lib/rb/ext/binary_protocol_accelerated.c @@ -300,7 +300,7 @@ VALUE rb_thrift_binary_proto_read_message_begin(VALUE self) { 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); } diff --git a/lib/rb/spec/binaryprotocol_spec_shared.rb b/lib/rb/spec/binaryprotocol_spec_shared.rb index a8a6e906..90371b35 100644 --- a/lib/rb/spec/binaryprotocol_spec_shared.rb +++ b/lib/rb/spec/binaryprotocol_spec_shared.rb @@ -208,6 +208,12 @@ shared_examples_for 'a binary protocol' do @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 -- 2.17.1