Skip to content

Conversation

@donoghuc
Copy link
Contributor

As a consumer of the mongo gem I want to run using jruby 10.

This commit starts this work, before I get too deep in it I want to make sure i'm not duplicating effort or if this is even something that would get any buy-in.

I noticed the first issue eaa3a1d attempting to even load the mongo gem. I attempted to add jruby 10 cells in CI to see other places that need update 63bdd19.

Thanks for looking :)

donoghuc added 2 commits May 15, 2025 10:56
The `fastGetModule` is deprecated in jruby 9.4 and removed in 10:

https://github.com/jruby/jruby/blob/1611c8e4e464164474a0e8c0663e16d67fa5c268/core/src/main/java/org/jruby/Ruby.java#L1373-L1385

This commit uses the getModule method (which should bridge between 9 and 10).
Note that it is marked deprecated in 10 but having the 9/10 compatability will
be a win in the forseable future.

https://github.com/jruby/jruby/blob/02c56b6099582500f86262a1d16d6b0e5cf3fe95/core/src/main/java/org/jruby/Ruby.java#L1339-L1342
@donoghuc donoghuc requested a review from a team as a code owner May 15, 2025 18:04
@donoghuc donoghuc requested a review from jamis May 15, 2025 18:04
donoghuc added a commit to donoghuc/opentelemetry-ruby-contrib that referenced this pull request May 15, 2025
It looks like latest features (including jruby 10 enablement) will require the
latest minor release of the mongo gem.

Specifically:

The latest mongo gem relaxes the range for the ruby-bson gem. This would allow
the uptake of mongodb/bson-ruby#353 if it is accepted.
@alexbevi
Copy link
Contributor

Hey @donoghuc, our team had https://jira.mongodb.org/browse/RUBY-3651 on our plan for this quarter to review but haven't kicked that off yet.

No duplication of effort at this point, and we'd be happy to get another set of eyes on it

donoghuc added a commit to donoghuc/opentelemetry-ruby-contrib that referenced this pull request May 16, 2025
It looks like latest features (including jruby 10 enablement) will require the
latest minor release of the mongo gem.

Specifically:

The latest mongo gem relaxes the range for the ruby-bson gem. This would allow
the uptake of mongodb/bson-ruby#353 if it is accepted.
arielvalentin pushed a commit to open-telemetry/opentelemetry-ruby-contrib that referenced this pull request May 27, 2025
* Add less restrictive gem spec for mongo gem

It looks like latest features (including jruby 10 enablement) will require the
latest minor release of the mongo gem.

Specifically:

The latest mongo gem relaxes the range for the ruby-bson gem. This would allow
the uptake of mongodb/bson-ruby#353 if it is accepted.

* Update test expectations based on latest mongo gem

This commit updates the test expectation for an updated message string. The same
behavior is observbed, the message has just been updated.

This commit also updates construction of a test mongodb client with a newly
required value for auth_source when building a simple client.
@codeowners-service-app codeowners-service-app bot requested a review from alexbevi May 30, 2025 02:44
@codeowners-service-app
Copy link

Assigned alexbevi for team dbx-ruby because jamis is out of office.

@gillesbergerp
Copy link

Is there still progress with this PR? I am happy to contribute as well if it would help

@comandeo-mongo comandeo-mongo self-assigned this Oct 10, 2025
@comandeo-mongo
Copy link
Contributor

Oh, my bad, it slipped out of my view. Sorry about that, I'll look into it. Thank you for the contribution!

@comandeo-mongo
Copy link
Contributor

@donoghuc @gillesbergerp There is one unexpected test failure on JRuby 10:

$ bundle exec rspec 'spec/bson/byte_buffer_write_spec.rb:730'
Source locally installed gems is ignoring #<Bundler::StubSpecification name=jruby-launcher version=2.0.1 platform=java> because it is missing extensions
Run options: include {locations: {"./spec/bson/byte_buffer_write_spec.rb" => [730]}}

  1) BSON::ByteBuffer#put_int64 when the integer is 64 bit when the integer is larger than 64 bit raises an exception
     Failure/Error:
       expect {
         buffer.put_int64(Integer::MAX_64BIT + 1)
       }.to raise_error(RangeError)

       expected RangeError but nothing was raised
     # ./spec/bson/byte_buffer_write_spec.rb:730:in 'block in <main>'

 1/1 |========================= 100 ==========================>| Time: 00:00:00

Finished in 0.35578 seconds (files took 0.69376 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/bson/byte_buffer_write_spec.rb:729 # BSON::ByteBuffer#put_int64 when the integer is 64 bit when the integer is larger than 64 bit raises an exception

Basically, getLongValue method behaves differently in JRuby 9 and 10 when the value is out of range. On JRuby 9 RangeError is raised, but on JRuby 10 the value is silently truncated.

I created a (relatively) simplified example that demonstrates the issue - https://github.com/10gen/get_long_value

I was not able to find any mention of getLongValue behaviour changes in JRuby 10 release notes, so I am not sure whether this is a bug or an expected situation.

The getLongValue method is deprecated. Use RubyNumeric#num2long instead.
this should be compatible with both jruby 9 and 10.
@donoghuc
Copy link
Contributor Author

donoghuc commented Oct 14, 2025

Thanks for the write up. I did some testing and proposed we use an alternate method which should preserve the behavior. I compared jruby-9.4.13.0 and jruby-10.0.2.0

@comandeo-mongo comandeo-mongo changed the title Add support for jruby 10 RUBY-3651 Add support for jruby 10 Oct 15, 2025
Copy link
Contributor

@alexbevi alexbevi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@comandeo-mongo comandeo-mongo merged commit b82034f into mongodb:master Oct 15, 2025
52 checks passed
@comandeo-mongo
Copy link
Contributor

@donoghuc Thank you so much for your contribution!

@comandeo-mongo comandeo-mongo added the feature Adds a new feature, without breaking compatibility label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds a new feature, without breaking compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants