Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruby2_keywords for delegation #1750

Merged
merged 1 commit into from Feb 21, 2022
Merged

Conversation

dentarg
Copy link
Member

@dentarg dentarg commented Feb 16, 2022

Follows "The Only Correct Way" from https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html

Related to #1670
Fixes #1749

@yaauie
Copy link

yaauie commented Feb 17, 2022

My minimal reproduction from #1670 passes with this patch "applied", and a Logstash that has had its plugin manager invoked resulting in Sinatra 2.2.0 being installed and run via jruby is also fixed by applying this patch:

diff --git a/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb b/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb
index 6ced0a6..986fe45 100644
--- a/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb
+++ b/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb
@@ -1533,10 +1533,11 @@ module Sinatra
       # Create a new instance of the class fronted by its middleware
       # pipeline. The object is guaranteed to respond to #call but may not be
       # an instance of the class new was called on.
-      def new(*args, **kwargs, &bk)
-        instance = new!(*args, **kwargs, &bk)
+      def new(*args, &bk)
+        instance = new!(*args, &bk)
         Wrapper.new(build(instance).to_app, instance)
       end
+      ruby2_keywords :new if respond_to?(:ruby2_keywords, true)
 
       # Creates a Rack::Builder instance with all the middleware set up and
       # the given +app+ as end point.

@jkowens jkowens merged commit 51ff33a into sinatra:master Feb 21, 2022
@kares
Copy link
Contributor

kares commented Feb 23, 2022

Hey @jkowens any chance to push 2.2.1 to unbreak JRuby users (accidentally) installing latest sinatra?

@jkowens
Copy link
Member

jkowens commented Feb 23, 2022

We'll have to check with @namusyaka to see about cutting a 2.2.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.2.0 regression in JRuby handling of inherited Sinatra::Base keyword args
5 participants