diff --git a/lib/bunny/session.rb b/lib/bunny/session.rb index afc032867..19677fe64 100644 --- a/lib/bunny/session.rb +++ b/lib/bunny/session.rb @@ -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) @@ -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