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: 2a7d6a974ab4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3211091b727b
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 29, 2016

  1. Fixes #3766. IO.copy_streams are not closing filename argument IO

    instances.
    
    Solution is to close any open IO instances which were not passed in
    as actual IO instances.
    enebo committed Mar 29, 2016
    Copy the full SHA
    04b8191 View commit details
  2. Copy the full SHA
    3211091 View commit details
Showing with 9 additions and 2 deletions.
  1. +7 −0 core/src/main/java/org/jruby/RubyIO.java
  2. +1 −1 spec/ruby/core/io/gets_spec.rb
  3. +1 −1 spec/ruby/core/io/read_spec.rb
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -4639,7 +4639,9 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv,
RubyInteger length = null;
RubyInteger offset = null;

boolean io1FromIO = false;
RubyIO io1 = null;
boolean io2FromIO = false;
RubyIO io2 = null;

RubyString read = null;
@@ -4655,6 +4657,7 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv,
if (arg1 instanceof RubyString) {
io1 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {arg1}, Block.NULL_BLOCK);
} else if (arg1 instanceof RubyIO) {
io1FromIO = true;
io1 = (RubyIO) arg1;
} else if (arg1.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg1, runtime.getString(), "to_path");
@@ -4672,6 +4675,7 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv,
if (arg2 instanceof RubyString) {
io2 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {arg2, runtime.newString("w")}, Block.NULL_BLOCK);
} else if (arg2 instanceof RubyIO) {
io2FromIO = true;
io2 = (RubyIO) arg2;
} else if (arg2.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg2, runtime.getString(), "to_path");
@@ -4732,6 +4736,9 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv,
}
} catch (BadDescriptorException e) {
throw runtime.newErrnoEBADFError();
} finally {
if (!io1FromIO && io1 != null && !io1.isClosed()) io1.ioClose(runtime);
if (!io2FromIO && io2 != null && !io2.isClosed()) io2.ioClose(runtime);
}
}

2 changes: 1 addition & 1 deletion spec/ruby/core/io/gets_spec.rb
Original file line number Diff line number Diff line change
@@ -167,8 +167,8 @@
end

after :each do
rm_r @name
@io.close
rm_r @name
end

it "calls #to_int to convert a single object argument to an Integer limit" do
2 changes: 1 addition & 1 deletion spec/ruby/core/io/read_spec.rb
Original file line number Diff line number Diff line change
@@ -289,8 +289,8 @@
end

after :each do
rm_r @fname
@io.close if @io and !@io.closed?
rm_r @fname
end

it "normalizes line endings in text mode" do