You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2016/09/25 16:43:43 UTC
[54/55] [abbrv] thrift git commit: Ensuring that HTTP failures will
clear the http transport outbuf var
Ensuring that HTTP failures will clear the http transport outbuf var
This closes #1048
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/eacbd65f
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/eacbd65f
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/eacbd65f
Branch: refs/heads/master
Commit: eacbd65f1d5aaae6cd2a4cdac89ffbba049f3558
Parents: a400c69
Author: John Thomas <th...@vt.edu>
Authored: Tue Jul 12 08:06:19 2016 -0700
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Mon Sep 26 01:42:02 2016 +0900
----------------------------------------------------------------------
lib/rb/lib/thrift/transport/http_client_transport.rb | 1 +
lib/rb/spec/http_client_spec.rb | 15 +++++++++++++++
2 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/eacbd65f/lib/rb/lib/thrift/transport/http_client_transport.rb
----------------------------------------------------------------------
diff --git a/lib/rb/lib/thrift/transport/http_client_transport.rb b/lib/rb/lib/thrift/transport/http_client_transport.rb
index 77ffe35..c9c4fec 100644
--- a/lib/rb/lib/thrift/transport/http_client_transport.rb
+++ b/lib/rb/lib/thrift/transport/http_client_transport.rb
@@ -50,6 +50,7 @@ module Thrift
data = resp.body
data = Bytes.force_binary_encoding(data)
@inbuf = StringIO.new data
+ ensure
@outbuf = Bytes.empty_byte_buffer
end
end
http://git-wip-us.apache.org/repos/asf/thrift/blob/eacbd65f/lib/rb/spec/http_client_spec.rb
----------------------------------------------------------------------
diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb
index 793fc73..5e8da24 100644
--- a/lib/rb/spec/http_client_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -67,6 +67,21 @@ describe 'Thrift::HTTPClientTransport' do
end
@client.flush
end
+
+ it 'should reset the outbuf on HTTP failures' do
+ @client.write "test"
+
+ Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
+ mock("Net::HTTP").tap do |http|
+ http.should_receive(:use_ssl=).with(false)
+ http.should_receive(:post).with("/path/to/service?param=value", "test", {"Content-Type"=>"application/x-thrift"}) { raise Net::ReadTimeout }
+ end
+ end
+
+ @client.flush rescue
+ @client.instance_variable_get(:@outbuf).should eq(Thrift::Bytes.empty_byte_buffer)
+ end
+
end
describe 'ssl enabled' do