Skip to content

NPE in ruby block called concurrently from Java #6282

@jmalves

Description

@jmalves

Environment Information

  • JRuby 9.2.7.0

Expected Behavior

No error when calling ruby block concurrently from Java

I have not been able to reproduce this error locally at all but seems to happen sporadically in our testing pipeline. The failing tests are different but a common pattern is passing a ruby block to java which is called concurrently. An example similar to our tests could be:

 results = java.util.concurrent.ConcurrentHashMap.new
 calculate_something_in_parallel(input1, input2, -> (id, result) { results[id] = result })

The stack trace then indicates that it fails when calling the lambda.

Actual Behavior

Returns an NPE with the following stack trace:

java.lang.NullPointerException 
     org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:127)
     org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:79)
     org.jruby.runtime.Block.call(Block.java:124)
     org.jruby.RubyProc.call(RubyProc.java:295)
     org.jruby.RubyProc.call(RubyProc.java:274)
     org.jruby.RubyProc.call(RubyProc.java:270)
     org.jruby.javasupport.Java$ProcToInterface.callProc(Java.java:1131)
     org.jruby.javasupport.Java$ProcToInterface.access$300(Java.java:1108)
     org.jruby.javasupport.Java$ProcToInterface$ConcreteMethod.call(Java.java:1169)
     org.jruby.gen.InterfaceImpl630006984.consume(org/jruby/gen/InterfaceImpl630006984.gen:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions