Skip to content

Commit 7b8f471

Browse files
committed
IO-122 - Helper classes for controlling closing of streams
- Added a finalizer to AutoCloseInputStream git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@608744 13f79535-47bb-0310-9956-ffa450edef68
1 parent 50f9c93 commit 7b8f471

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/java/org/apache/commons/io/input/AutoCloseInputStream.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,14 @@ public int read(byte[] b, int off, int len) throws IOException {
115115
return n;
116116
}
117117

118+
/**
119+
* Ensures that the stream is closed before it gets garbage-collected.
120+
* As mentioned in {@link #close()}, this is a no-op if the stream has
121+
* already been closed.
122+
*/
123+
protected void finalize() throws Throwable {
124+
close();
125+
super.finalize();
126+
}
127+
118128
}

0 commit comments

Comments
 (0)