Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0c749ca88da7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 106ad0f49f7b
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 9, 2017

  1. Copy the full SHA
    64c7ea0 View commit details
  2. Copy the full SHA
    106ad0f View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyMarshal.java
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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,15 +185,15 @@ 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);
}
return result;
}

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);
}
11 changes: 11 additions & 0 deletions spec/ruby/core/marshal/shared/load.rb
Original file line number Diff line number Diff line change
@@ -58,6 +58,17 @@
end
end

describe "when called with nil for the proc argument" do
it "behaves as if no proc argument was passed" do
a = [1]
a << a
lambda do
b = Marshal.send(@method, Marshal.dump(a), nil)
b.should == a
end.should_not raise_error
end
end

describe "when called on objects with custom _dump methods" do
it "does not set instance variables of an object with user-defined _dump/_load" do
# this string represents: <#UserPreviouslyDefinedWithInitializedIvar @field2=7 @field1=6>