Skip to content

Commit

Permalink
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -111,12 +111,16 @@ public static RubyClass createDirClass(Ruby runtime) {
}

private final void checkDir() {
testFrozen("Dir");
update();
checkDirIgnoreClosed();

if (!isOpen) throw getRuntime().newIOError("closed directory");
}

private final void checkDirIgnoreClosed() {
testFrozen("Dir");
update();
}

private void update() {
if (snapshot == null || dir.exists() && dir.lastModified() > lastModified) {
lastModified = dir.lastModified();
@@ -514,7 +518,7 @@ public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyO
@JRubyMethod(name = "close")
public IRubyObject close() {
// Make sure any read()s after close fail.
checkDir();
checkDirIgnoreClosed();

isOpen = false;

0 comments on commit 4cccba8

Please sign in to comment.