You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:16:11 UTC
svn commit: r669000 - in /incubator/thrift/trunk/lib/rb:
lib/thrift/transport/socket.rb spec/socket_spec.rb
Author: kclark
Date: Tue Jun 17 18:16:11 2008
New Revision: 669000
URL: http://svn.apache.org/viewvc?rev=669000&view=rev
Log:
rb: Thrift::Socket should return false from #open? if an error occurred during a read/write (THRIFT-7)
Modified:
incubator/thrift/trunk/lib/rb/lib/thrift/transport/socket.rb
incubator/thrift/trunk/lib/rb/spec/socket_spec.rb
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/transport/socket.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/transport/socket.rb?rev=669000&r1=668999&r2=669000&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/transport/socket.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/transport/socket.rb Tue Jun 17 18:16:11 2008
@@ -35,6 +35,8 @@
begin
@handle.write(str)
rescue StandardError
+ @handle.close
+ @handle = nil
raise TransportException.new(TransportException::NOT_OPEN)
end
end
@@ -47,6 +49,8 @@
data = @handle.read(sz)
end
rescue StandardError => e
+ @handle.close
+ @handle = nil
raise TransportException.new(TransportException::NOT_OPEN, e.message)
end
if (data.nil? or data.length == 0)
Modified: incubator/thrift/trunk/lib/rb/spec/socket_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/socket_spec.rb?rev=669000&r1=668999&r2=669000&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/socket_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/socket_spec.rb Tue Jun 17 18:16:11 2008
@@ -6,6 +6,7 @@
before(:each) do
@socket = Socket.new
@handle = mock("Handle")
+ @handle.stub!(:close)
end
describe Socket do
@@ -68,14 +69,12 @@
end
it "should declare itself as closed when it has an error" do
- pending do
- TCPSocket.should_receive(:new).and_return(@handle)
- @socket.open
- @handle.should_receive(:write).with("fail").and_raise(StandardError)
- @socket.should be_open
- lambda { @socket.write("fail") }.should raise_error
- @socket.should_not be_open
- end
+ TCPSocket.should_receive(:new).and_return(@handle)
+ @socket.open
+ @handle.should_receive(:write).with("fail").and_raise(StandardError)
+ @socket.should be_open
+ lambda { @socket.write("fail") }.should raise_error
+ @socket.should_not be_open
end
end