| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Solves jruby#8854 Prevents `Time.new(2023, 2, 1, **{})` from raising NullPointerException when accessing `opts` which can happened when keyword args are empty, e.g: https://github.com/rails/rails/blob/v7.1.5.1/activesupport/lib/active_support/testing/time_helpers.rb#L185 Unsure if this is the best way, but it does the job for now I think. I realised that if keywords was empty, `hasKeywords` still returns true and `extractKeywordArgs` returns null, and `args` doesn't have the Hash object, it is just missing. So that is why we can only subtract 1 from argc after `extractKeywordArgs` and confirming it is not null. It feels there is a more general problem of how keywords are handled or/and a missing helper to avoid these issues as I think this bug may be in a couple more places in the codebase, but probably people don't hit them frequently. I added a test for it since it was a regression from JRuby v9, but also unsure where best to put the test or if it is something we want / need. Feel free to make any changes or suggestions.
|
Hey sorry I missed this, it's been a busy month! Thanks so much for pitching in and fixing these issues! I'll review today and get it merged for future releases. |
Sorry, something went wrong.
|
Looks good to me. Typical case of us not using new mechanism for detecting keywords. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #8854 and #8860.
#8854 irb> Time.new(2025, 4, 3, **{}) org.jruby.dist/org.jruby.RubyTime.initialize(RubyTime.java:1758): Cannot load from object array because "opts" is null (Java::JavaLang::NullPointerException) #8860 irb> Time.new(2025, 4, 3, in: 'UTC') => 2025-04-01 00:00:00 +0000 # The day is incorrect. It always loses the last arg.The travel_to test helper from ActiveSupport triggers the empty keywords issue.
As a result of fixing the NullPointerException and writing a regression test, it actually triggered the other issue of losing the last argument when using keywords.
I realised that if keywords was empty, hasKeywords still returns true and extractKeywordArgs returns null, and args doesn't have the Hash object, it is just missing. So that is why we can only subtract 1 from argc after extractKeywordArgs and confirming it is not null. Also, since we are already subtracting one, then we don't need the keywords condition again in the argc switch.
I added a test for it since it was a regression from JRuby v9.