Skip to content

Use ruby2_keywords for delegation#1750

Merged
jkowens merged 1 commit intosinatra:masterfrom
dentarg:fix-delegation
Feb 21, 2022
Merged

Use ruby2_keywords for delegation#1750
jkowens merged 1 commit intosinatra:masterfrom
dentarg:fix-delegation

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