Skip to content

Profiler raises 'wrong number of arguments for constructor (ArgumentError)' for the march_hare gem #8148

@kevinwatson

Description

@kevinwatson

Environment Information

jruby -v
jruby 9.4.6.0 (3.1.4) 2024-02-20 576fab2c51 OpenJDK 64-Bit Server VM 17.0.10+7 on 17.0.10+7 +jit [aarch64-linux]
uname -a
Linux a2fbb69ea12d 5.15.82-0-virt #1-Alpine SMP Mon, 12 Dec 2022 09:15:17 +0000 aarch64 aarch64 aarch64 GNU/Linux

gem march_hare
env vars JRUBY_OPTS=--profile.api

Expected Behavior

The march_hare gem should be able to connect to rabbitmq and initialize its exception handler

Actual Behavior

irb(main):002:0> MarchHare.connect(host: 'rabbit')
/usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:692:in `init_default_exception_handler': wrong number of arguments for constructor (ArgumentError)
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:153:in `initialize'
	from org/jruby/RubyClass.java:935:in `new'
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:132:in `connect'
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare.rb:24:in `connect'
	from (irb):2:in `evaluate'
	from org/jruby/RubyKernel.java:1265:in `eval'
	from org/jruby/RubyKernel.java:1707:in `loop'
	from org/jruby/RubyKernel.java:1414:in `catch'
	from org/jruby/RubyKernel.java:1414:in `catch'
	from /opt/jruby/lib/ruby/gems/shared/gems/irb-1.4.2/exe/irb:11:in `<main>'
	from org/jruby/RubyKernel.java:1211:in `load'
	from /opt/jruby/bin/irb:25:in `<main>'

https://github.com/ruby-amqp/march_hare/blob/main/lib/march_hare/exception_handler.rb#L2

This docker compose file can be used to test this behavior

# compose.yml
services:
  console:
    image: jruby:9.4-jdk17
    depends_on:
    - rabbit
  rabbit:
    image: rabbitmq:latest
    ports:
    - 5672:5672

Works successfully when --profile.api is not set

docker-compose run console bash

gem install march_hare
irb

require 'march_hare'
MarchHare.connect(host: 'rabbit')
=>
#<MarchHare::Session:0xc1f0c7b
 @addresses=["rabbit"],
 @automatic_recovery_hook=
  #<MarchHare::ShutdownListener:0x3a7d914c
   @block=#<Proc:0x5100c143 /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:308>,
   @entity=#<MarchHare::Session:0xc1f0c7b ...>>,
 @automatically_recover=true,
...

Error when --profile.api is set

docker-compose run console bash

gem install march_hare
export JRUBY_OPTS=--profile.api
irb

require 'march_hare'
MarchHare.connect(host: 'rabbit')
/usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:692:in `init_default_exception_handler': wrong number of arguments for constructor (ArgumentError)
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:153:in `initialize'
	from org/jruby/RubyClass.java:935:in `new'
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare/session.rb:132:in `connect'
	from /usr/local/bundle/gems/march_hare-4.6.0-java/lib/march_hare.rb:24:in `connect'
	from (irb):2:in `evaluate'
	from org/jruby/RubyKernel.java:1265:in `eval'
	from org/jruby/RubyKernel.java:1707:in `loop'
	from org/jruby/RubyKernel.java:1414:in `catch'
	from org/jruby/RubyKernel.java:1414:in `catch'
	from /opt/jruby/lib/ruby/gems/shared/gems/irb-1.4.2/exe/irb:11:in `<main>'
	from org/jruby/RubyKernel.java:1211:in `load'
	from /opt/jruby/bin/irb:25:in `<main>'

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