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

NPE json nested-array regression #5929

Closed
ahorek opened this issue Oct 20, 2019 · 1 comment · Fixed by #5930
Closed

NPE json nested-array regression #5929

ahorek opened this issue Oct 20, 2019 · 1 comment · Fixed by #5930
Assignees
Labels
Milestone

Comments

@ahorek
Copy link
Contributor

@ahorek ahorek commented Oct 20, 2019

Environment

Provide at least:
jruby 9.2.9.0-SNAPSHOT (2.5.7) 2019-10-20 ebab3d4 Java HotSpot(TM) 64-Bit Server VM 11.0.1+13-LTS on 11.0.1+13-LTS +jit [mswin32-x86_64]

bisected to b9bd393

cc @kares

Expected Behavior

require 'json'

class SubArray2 < Array
  def to_json(*a)
    {
      JSON.create_id => self.class.name,
      'ary'          => to_a,
    }.to_json(*a)
  end
end

JSON(SubArray2["foo"])
=> "{\"json_class\":\"SubArray2\",\"ary\":[\"foo\"]}"

Actual Behavior

java.lang.NullPointerException: null
           eltInternal at org/jruby/RubyArray.java:905
              generate at json/ext/Generator.java:306
              generate at json/ext/Generator.java:272
                 visit at json/ext/Generator.java:377
                 visit at org/jruby/RubyHash.java:676
          visitLimited at org/jruby/RubyHash.java:698
              visitAll at org/jruby/RubyHash.java:2744
              generate at json/ext/Generator.java:356
              generate at json/ext/Generator.java:329
           generateNew at json/ext/Generator.java:194
          generateJson at json/ext/Generator.java:37
               to_json at json/ext/GeneratorMethods.java:70
                  call at json/ext/GeneratorMethods$RbHash$INVOKER$s$0$0$to_json.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:343
                  call at org/jruby/runtime/callsite/CachingCallSite.java:76
  invokeOther5:to_json at testik.rb:6
               to_json at testik.rb:6
                  call at org/jruby/internal/runtime/methods/CompiledIRMethod.java:154
               finvoke at org/jruby/RubyClass.java:788
                invoke at org/jruby/runtime/Helpers.java:459
            callMethod at org/jruby/RubyBasicObject.java:373
           generateNew at json/ext/Generator.java:451
          generateJson at json/ext/Generator.java:59
              generate at json/ext/GeneratorState.java:209
                  call at json/ext/GeneratorState$INVOKER$i$1$0$generate.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:375
                  call at org/jruby/runtime/callsite/CachingCallSite.java:174
           processCall at org/jruby/ir/interpreter/InterpreterEngine.java:316
             interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:72
             interpret at org/jruby/ir/interpreter/InterpreterEngine.java:92
      INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:205
                  call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:192
                  call at org/jruby/internal/runtime/methods/DynamicMethod.java:208
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:396
                  call at org/jruby/runtime/callsite/CachingCallSite.java:205
           processCall at org/jruby/ir/interpreter/InterpreterEngine.java:325
             interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:72
             interpret at org/jruby/ir/interpreter/InterpreterEngine.java:86
      INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:170
                  call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:157
                  call at org/jruby/internal/runtime/methods/DynamicMethod.java:200
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:375
                  call at org/jruby/runtime/callsite/CachingCallSite.java:174
     invokeOther7:JSON at testik.rb:12
                <main> at testik.rb:12
   invokeWithArguments at java/lang/invoke/MethodHandle.java:710
                  load at org/jruby/ir/Compiler.java:89
             runScript at org/jruby/Ruby.java:855
           runNormally at org/jruby/Ruby.java:778
           runNormally at org/jruby/Ruby.java:796
           runFromMain at org/jruby/Ruby.java:608
         doRunFromMain at org/jruby/Main.java:412
           internalRun at org/jruby/Main.java:304
                   run at org/jruby/Main.java:234
                  main at org/jruby/Main.java:206
@kares

This comment has been minimized.

Copy link
Member

@kares kares commented Oct 21, 2019

Thanks Pavel (esp. for doing the bisect), I will make sure this is fixed before 9.2.9.0 is released.

@kares kares self-assigned this Oct 21, 2019
@kares kares added this to the JRuby 9.2.9.0 milestone Oct 21, 2019
@kares kares closed this in #5930 Oct 21, 2019
kares added a commit that referenced this issue Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.