Skip to content

Commit

Permalink
Be more defensive: handle authentication mechanism lists that are blank
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Dec 18, 2017
1 parent c8a64b5 commit b1d99d9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/bunny/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def initialize(connection_string_or_opts = ENV['RABBITMQ_URL'], optz = Hash.new)

client_props = opts[:properties] || opts[:client_properties] || {}
@client_properties = DEFAULT_CLIENT_PROPERTIES.merge(client_props)
@mechanism = opts.fetch(:auth_mechanism, "PLAIN")
@mechanism = normalize_auth_mechanism(opts.fetch(:auth_mechanism, "PLAIN"))
@credentials_encoder = credentials_encoder_for(@mechanism)
@locale = @opts.fetch(:locale, DEFAULT_LOCALE)

Expand Down Expand Up @@ -1394,6 +1394,17 @@ def normalize_client_channel_max(n)
end
end

def normalize_auth_mechanism(value)
case value
when [] then
"PLAIN"
when nil then
"PLAIN"
else
value
end
end

def ignoring_io_errors(&block)
begin
block.call
Expand Down

0 comments on commit b1d99d9

Please sign in to comment.