PROTON-1724: Revert "PROTON-1721 [ruby] resovler errors are not handled correctly"
This reverts commit c4d5fde71d925f3f44b0e29d672de7b039ee709f.
In the context of Ruby it is better to raise these exceptions immediately than to
bury them as events.
diff --git a/proton-c/bindings/ruby/lib/core/container.rb b/proton-c/bindings/ruby/lib/core/container.rb
index e16323b..7a69b58 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -41,18 +41,6 @@
end
end
- # Used as the @io when a socket cannot be created due to an erro (e.g resolver fails)
- # Saves the error and raises it in on_readable so it can be reported via normal channels.
- class BrokenSocket
- def initialize(msg) @error = IOError.new(msg); end
- [:read_nonblock, :write_nonblock, :accept].each do |m|
- define_method(m) { |*args| raise @error }
- end
- [:close_read, :close_write, :close].each do |m|
- define_method(m) {}
- end
- end
-
class ListenTask < Listener
def initialize(io, handler, container)
@@ -190,12 +178,7 @@
opts[:password] ||= url.password
end
opts[:ssl_domain] ||= SSLDomain.new(SSLDomain::MODE_CLIENT) if url.scheme == "amqps"
- socket = begin
- TCPSocket.new(url.host, url.port)
- rescue => e
- BrokenSocket.new("connect(#{url}): #{e}")
- end
- connect_io(socket, opts)
+ connect_io(TCPSocket.new(url.host, url.port), opts)
end
# Open an AMQP protocol connection on an existing {IO} object
@@ -220,12 +203,7 @@
not_stopped
url = Qpid::Proton::uri url
# TODO aconway 2017-11-01: amqps, SSL
- server = begin
- TCPServer.new(url.host, url.port)
- rescue => e
- BrokenSocket.new("listen(#{url}): #{e}")
- end
- listen_io(server, handler)
+ listen_io(TCPServer.new(url.host, url.port), handler)
end
# Listen for incoming AMQP connections on an existing server socket.
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index f2ad1f1..71a9f3a 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -152,11 +152,8 @@
def test_bad_host
cont = Container.new(__method__)
- l = cont.listen("badlisten.example.com:999")
- c = cont.connect("badconnect.example.com:999")
- cont.run
- assert_match(/badlisten.example.com:999/, l.condition.description)
- assert_match(/badconnect.example.com:999/, c.transport.condition.description)
+ assert_raises (SocketError) { cont.listen("badlisten.example.com:999") }
+ assert_raises (SocketError) { c = cont.connect("badconnect.example.com:999") }
end
# Verify that connection options are sent to the peer and available as Connection methods