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

Fix helper class used for config.webxml values #513

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

JesseChavez
Copy link
Contributor

This fixes the issue reported in theJRuby repo:

jruby/jruby#7160

Basically the issue was caused due 2 changes in the ostruct repo:

change 1:

commit d39c4e3feab2852f45cff791cf8cd684960c07a1
Refs:
Author:     nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
AuthorDate: Mon Jan 5 01:57:26 2015 +0000
Commit:     nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
CommitDate: Mon Jan 5 01:57:26 2015 +0000

    ostruct.rb: append suffixes to protected methods

    * lib/ostruct.rb (modifiable?, new_ostruct_member!, table!):
      append suffixes to protected methods so that they will not clash
      with assigned members.  [Fix GH-806]

    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

change 2:

commit 6dbc902092249ae2c75546fd121ba7618d3645c7
Refs: v0.1.0-33-g6dbc902
Author:     Marc-Andre Lafortune <[email protected]>
AuthorDate: Mon Sep 14 14:06:49 2020 -0400
Commit:     Marc-Andre Lafortune <[email protected]>
CommitDate: Mon Sep 14 16:13:45 2020 -0400

    method_missing is private

@olleolleolle
Copy link
Member

olleolleolle commented Apr 7, 2022

@JesseChavez 👋 Hi! This is super-clear, you added good context information in the commit message, good to have links to background information!

I saw that jruby-head tests were failing on something minor, so I started a PR to see if we could work around that for jruby-head. #514 Edit: Now merged.

@olleolleolle
Copy link
Member

olleolleolle commented Apr 7, 2022

Also, the relevant change - adding the ! methods - was made five years ago, I think we should see it as supported.

Edit: So, if you rebase, perhaps we can see this run green on jruby-head, too?

@enebo
Copy link
Member

enebo commented Apr 7, 2022

@olleolleolle This is a weird failure. How is the rubygems being run so old if we are running a JRuby 3.1.x codebase which has its own rubygems?

@olleolleolle
Copy link
Member

@olleolleolle This is a weird failure. How is the rubygems being run so old if we are running a JRuby 3.1.x codebase which has its own rubygems?

Because the steps that are installing RubyGems were installing a very specific version. I changed it in #514.

@headius
Copy link
Member

headius commented Apr 7, 2022

Good work all around, folks!

@headius
Copy link
Member

headius commented Apr 7, 2022

Because the steps that are installing RubyGems were installing a very specific version. I changed it in #514.

@JesseChavez Could you rebase on current warbler master so we can see that it is green across the board?

@JesseChavez JesseChavez force-pushed the fix_webxml_open_struct branch from 4ba7e29 to fb904dc Compare April 7, 2022 17:02
@JesseChavez
Copy link
Contributor Author

@headius , I've rebased it

@enebo
Copy link
Member

enebo commented Apr 7, 2022

All green!

@olleolleolle olleolleolle merged commit c65a44c into jruby:master Apr 8, 2022
@olleolleolle
Copy link
Member

Exquisite! I went ahead and merged this change. 🎉 Thanks, @JesseChavez! And thanks all who chimed in!

@johnnyb
Copy link

johnnyb commented Apr 26, 2022

I'm trying to use this (gem installed from git to main repo), but it is now saying, "TypeError: nil is not a string" when trying to evaluate config.webxml.jruby.min.runtimes = 1 in "lib/warbler/traits/rails.rb". new_ostruct_member!("runtimes") is returning nil apparently.

@olleolleolle
Copy link
Member

@headius Oh, hi, this last comment looks a lot like the issue you and others have been fighting in OpenStruct. Can you offer any insight?

@olleolleolle
Copy link
Member

@johnnyb To make debugging this easier, can you say what jruby that is, and what version of OpenStruct is in use (recently made into a separate gem)?

@sebastianguarin
Copy link

@olleolleolle is this change in any version? don't want to force master for Prod.

@olleolleolle
Copy link
Member

olleolleolle commented May 16, 2022

@sebastianguarin Answer: not yet released. See #498 for what is left.

@nbekirov
Copy link

@olleolleolle Any chance of this getting a minor release instead of waiting for the 2.1.0?

@joerixaop
Copy link
Contributor

This fix is still broken on 9.3.6.0. The #modifiable method is no longer part of ostruct in that release.
The result of that is the following confusing behaviour:

irb(main):036:0> c = Warbler::Traits::War::WebxmlOpenStruct.new
=> #<Warbler::Traits::War::WebxmlOpenStruct>
irb(main):037:0> c.rails.env = 'production'
=> "production"
irb(main):038:0> c.rails.env
=> #<Warbler::Traits::War::WebxmlOpenStruct>
irb(main):039:0> c.rails.env = 'production'
=> "production"
irb(main):040:0> c.rails.env
=> "production"
irb(main):041:0> c
=> #<Warbler::Traits::War::WebxmlOpenStruct rails=#<Warbler::Traits::War::WebxmlOpenStruct modifiable=#<Warbler::Traits::War::WebxmlOpenStruct name=#<Warbler::Traits::War::WebxmlOpenStruct>, No value for 'name' found="production">, env="production">>

The fix for this is "simple": instead of the line
modifiable[new_ostruct_member!(mname)] = args[0]
it should be
set_ostruct_member_value!(mname, args[0]), the catch is that that won't work on JRuby 9.2.

@JesseChavez
Copy link
Contributor Author

Looking deeper in the open struct code the current method_missing, the implementation of in warbler is copy and paste from and older version of open struct.

https://github.com/ruby/ostruct/blob/1ea1438e592b7407654d0ead49f3a20f813a44cc/lib/ostruct.rb#L175

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.

8 participants