Skip to content

MaxRetry with {} Queue Option Argument throwing Nil Error #21

Closed
@anuonifade

Description

@anuonifade

When Using a MaxRetry handler option for Queues and Queue Option argument is an empty hash, it throws an error.

name = "sample-max-retry"
opts[:queue_options] = {:durable=>true, :auto_delete=>false, :exclusive=>false, :arguments=>{}}
Sneakers::Handlers::Maxretry.configure_queue(
  name,
  opts
)

The line

opt_args = opts[:queue_options][:arguments] ? opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} : {}
will throw an error.

opts[:queue_options][:arguments] ? will return true and trying to inject and empty hash will raise an error.

Changing the line

opt_args = opts[:queue_options][:arguments] ? opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} : {}

To

opt_args = opts[:queue_options][:arguments].blank? ?  {} :  opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}

Should fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions