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

Commits on Feb 24, 2017

  1. Copy the full SHA
    67bcda5 View commit details
  2. Copy the full SHA
    241db76 View commit details
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/RubyFileTest.java
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.JRubyFile;
import org.jruby.util.FileResource;
import org.jruby.util.NullDeviceResource;
import org.jruby.util.TypeConverter;

@JRubyModule(name = "FileTest")
@@ -311,7 +312,13 @@ public static RubyBoolean zero_p(IRubyObject recv, IRubyObject filename) {
public static RubyBoolean zero_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
Ruby runtime = context.runtime;

FileStat stat = fileResource(context, filename).stat();
FileResource resource = fileResource(context, filename);

// FIXME: Ultimately we should return a valid stat() from this but without massive NUL coverage
// this is less risky.
if (resource instanceof NullDeviceResource) return runtime.newBoolean(true);

FileStat stat = resource.stat();

if (stat == null) return runtime.getFalse();
// MRI behavior, enforced by RubySpecs.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/NullDeviceResource.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
/**
* Represents a the NUL: device on Windows, which is not a normal file.
*/
class NullDeviceResource extends AbstractFileResource {
public class NullDeviceResource extends AbstractFileResource {
private static final JRubyFile file = new JRubyFile("NUL:");
private final POSIX posix;

1 change: 0 additions & 1 deletion spec/tags/ruby/core/file/zero_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/ruby/core/filetest/zero_tags.txt

This file was deleted.