Fix the exception message shown when there's an IOError
while closing a socket in the pool.
This commit is contained in:
parent
9076432c48
commit
fa0a933780
|
@ -49,8 +49,7 @@ module Mongo
|
||||||
begin
|
begin
|
||||||
sock.close
|
sock.close
|
||||||
rescue IOError => ex
|
rescue IOError => ex
|
||||||
warn "IOError when attempting to close socket connected "
|
warn "IOError when attempting to close socket connected to #{@host}:#{@port}: #{ex.inspect}"
|
||||||
+ "to #{@host}:#{@port}: #{ex.inspect}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@host = @port = nil
|
@host = @port = nil
|
||||||
|
|
|
@ -264,5 +264,15 @@ class TestConnection < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_equal 0, @con.primary_pool.checked_out.size
|
assert_equal 0, @con.primary_pool.checked_out.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "show a proper exception message if an IOError is raised while closing a socket" do
|
||||||
|
fake_socket = Mocha::Mock.new
|
||||||
|
fake_socket.stubs(:close).raises(IOError.new)
|
||||||
|
fake_socket.stub_everything
|
||||||
|
TCPSocket.expects(:new).returns(fake_socket)
|
||||||
|
|
||||||
|
@con.primary_pool.checkout_new_socket
|
||||||
|
assert_equal [], @con.primary_pool.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue