Ruby 3.0 modernisation, code quality improvements, and gem cleanup#735
Merged
Merged
Conversation
Several queue helper methods (quorum_queue, stream, durable_queue, delayed_queue, jms_queue, queue) used `throw ArgumentError.new(...)` to signal validation errors. With no matching `catch` block, Ruby raises `UncaughtThrowError` rather than `ArgumentError`, which is neither the documented nor intended behavior. Switch these call sites to `raise ArgumentError, "..."` and update the existing specs that asserted `UncaughtThrowError` to expect `ArgumentError` instead.
Sweep the remaining `:key =>` hash rocket syntax in lib/ over to the modern `key:` form. Covers default option hashes, merge calls, DEFAULT_CLIENT_PROPERTIES, return/delivery/get_response to_hash outputs, and docstring examples. Also drop the redundant `# encoding: utf-8` magic comment from version.rb (UTF-8 is the default source encoding since Ruby 2.0).
Member
|
The failures are connection recovery flakes. I will get to them eventually. |
michaelklishin
added a commit
that referenced
this pull request
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
These messaging gems are critical dependencies in our production app, so I've been investing time in modernising the RabbitMQ Ruby ecosystem (hutch, amq-protocol) and want to contribute similar cleanup to Bunny. This PR removes accumulated legacy code and tightens things up for the Ruby 3.0+ baseline Bunny already requires.
Changes
Ruby 3.0 modernisation
defined? Encoding,respond_to?(:report_on_exception), encoding magic comments,require "thread",require "monitor"):key =>hash rocket syntax inlib/over tokey:Bug fix
quorum_queue,stream,durable_queue,delayed_queue,jms_queue,queue) usedthrow ArgumentError.new(...)to signal validation errors. With no matchingcatch, this raisesUncaughtThrowErrorinstead ofArgumentError. Switched toraise ArgumentError, "..."and updated the specs that asserted the wrong error classCode quality
@channels[ch_number]hash lookup inhandle_frameset— single lookup per frame instead of tworespond_to?(:name)duck-type checks withis_a?(Bunny::Exchange)/is_a?(Bunny::Queue)in the publish, bind, and consumer hot pathsGem / Gemfile cleanup
amq-protocolto~> 2.7to match the runtime dependency