Skip to content

Commit

Permalink
second connect would fail when using same option hash as first connect
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo committed Sep 26, 2011
1 parent 52ca906 commit fb63acb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/nats/client.rb
Expand Up @@ -72,7 +72,7 @@ class << self
# The optional block will be called when the connection has been completed.
#
# @param [Hash] opts
# @option opts [String] :uri The URI to connect to, example nats://localhost:4222
# @option opts [String|URI] :uri The URI to connect to, example nats://localhost:4222
# @option opts [Boolean] :autostart Boolean that can be used to engage server autostart functionality.
# @option opts [Boolean] :reconnect Boolean that can be used to suppress reconnect functionality.
# @option opts [Boolean] :debug Boolean that can be used to output additional debug information.
Expand All @@ -98,7 +98,7 @@ def connect(opts={}, &blk)
opts[:reconnect] = ENV['NATS_RECONNECT'].downcase == 'true' unless ENV['NATS_RECONNECT'].nil?
opts[:max_reconnect_attempts] = ENV['NATS_MAX_RECONNECT_ATTEMPTS'].to_i unless ENV['NATS_MAX_RECONNECT_ATTEMPTS'].nil?
opts[:reconnect_time_wait] = ENV['NATS_RECONNECT_TIME_WAIT'].to_i unless ENV['NATS_RECONNECT_TIME_WAIT'].nil?
@uri = opts[:uri] = URI.parse(opts[:uri])
@uri = opts[:uri] = opts[:uri].is_a?(URI) ? opts[:uri] : URI.parse(opts[:uri])
@err_cb = proc {|e| raise e } unless err_cb
check_autostart(@uri) if opts[:autostart] == true

Expand Down
6 changes: 6 additions & 0 deletions spec/client_spec.rb
Expand Up @@ -295,4 +295,10 @@
got_error.should be_true
end

it 'should accept the same option set twice' do
opts = {:uri => 'nats://localhost:4222'}
NATS.start(opts) { NATS.stop }
NATS.start(opts) { NATS.stop }
end

end

0 comments on commit fb63acb

Please sign in to comment.