diff --git a/core/src/main/java/org/jruby/RubyMarshal.java b/core/src/main/java/org/jruby/RubyMarshal.java index 49d8b96f80c..55181fa9084 100644 --- a/core/src/main/java/org/jruby/RubyMarshal.java +++ b/core/src/main/java/org/jruby/RubyMarshal.java @@ -124,7 +124,7 @@ private static void setBinmodeIfPossible(ThreadContext context, IRubyObject io) public static IRubyObject load(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) { Ruby runtime = context.runtime; IRubyObject in = args[0]; - IRubyObject proc = args.length == 2 ? args[1] : null; + IRubyObject proc = args.length == 2 ? args[1] : context.nil; try { InputStream rawInput; diff --git a/core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java b/core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java index 7c9acaf893c..b90f6cc52d9 100644 --- a/core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java +++ b/core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java @@ -77,6 +77,10 @@ public class UnmarshalStream extends InputStream { private final boolean taint; public UnmarshalStream(Ruby runtime, InputStream in, IRubyObject proc, boolean taint) throws IOException { + assert runtime != null; + assert in != null; + assert proc != null; + this.runtime = runtime; this.cache = new UnmarshalCache(runtime); this.proc = proc; @@ -181,7 +185,7 @@ private static RubyModule getConstantFromPath(Ruby runtime, String path) { } private IRubyObject doCallProcForLink(IRubyObject result, int type) { - if (proc != null && type != ';') { + if (!proc.isNil() && type != ';') { // return the result of the proc, but not for symbols return Helpers.invoke(getRuntime().getCurrentContext(), proc, "call", result); } @@ -189,7 +193,7 @@ private IRubyObject doCallProcForLink(IRubyObject result, int type) { } private IRubyObject doCallProcForObj(IRubyObject result) { - if (proc != null) { + if (!proc.isNil()) { // return the result of the proc, but not for symbols return Helpers.invoke(getRuntime().getCurrentContext(), proc, "call", result); }