Skip to content

Commit 6562738

Browse files
committedJun 8, 2018
make RubyDir implement Closeable (to align with RubyFile)
1 parent 8d73b22 commit 6562738

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎core/src/main/java/org/jruby/RubyDir.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
package org.jruby;
3434

35+
import java.io.Closeable;
3536
import java.io.File;
3637
import java.io.FileInputStream;
3738
import java.io.IOException;
@@ -69,7 +70,7 @@
6970
* @author jvoegele
7071
*/
7172
@JRubyClass(name = "Dir", include = "Enumerable")
72-
public class RubyDir extends RubyObject {
73+
public class RubyDir extends RubyObject implements Closeable {
7374
private RubyString path; // What we passed to the constructor for method 'path'
7475
protected FileResource dir;
7576
private long lastModified = Long.MIN_VALUE;
@@ -649,13 +650,15 @@ public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyO
649650
* Closes the directory stream.
650651
*/
651652
@JRubyMethod(name = "close")
652-
public IRubyObject close() {
653+
public IRubyObject close(ThreadContext context) {
654+
close();
655+
return context.nil;
656+
}
657+
658+
public final void close() {
653659
// Make sure any read()s after close fail.
654660
checkDirIgnoreClosed();
655-
656661
isOpen = false;
657-
658-
return getRuntime().getNil();
659662
}
660663

661664
/**

0 commit comments

Comments
 (0)
Please sign in to comment.