jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r740262 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db: DbInputStream.java TempFileInputStream.java
Date Tue, 03 Feb 2009 10:11:42 GMT
Author: thomasm
Date: Tue Feb  3 10:11:42 2009
New Revision: 740262

URL: http://svn.apache.org/viewvc?rev=740262&view=rev
Log:
JCR-1934 DbDataStore: delete temporary files using finalize()

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java?rev=740262&r1=740261&r2=740262&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
Tue Feb  3 10:11:42 2009
@@ -18,9 +18,9 @@
 
 import java.io.EOFException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.sql.ResultSet;
 
+import org.apache.commons.io.input.AutoCloseInputStream;
 import org.apache.jackrabbit.core.data.DataIdentifier;
 import org.apache.jackrabbit.core.data.DataStoreException;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager;
@@ -28,19 +28,17 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * This class represents an input stream backed by a database. It allows the
- * stream to be used by keeping the database objects open until the stream is
- * closed. When the stream is finished or closed, then the database objects are
- * freed.
+ * This class represents an input stream backed by a database. The database
+ * objects are only acquired when reading from the stream, and stay open until
+ * the stream is closed, fully read, or garbage collected.
  */
-public class DbInputStream extends InputStream {
+public class DbInputStream extends AutoCloseInputStream {
 
     private static Logger log = LoggerFactory.getLogger(DbInputStream.class);
 
     protected DbDataStore store;
     protected DataIdentifier identifier;
     protected boolean endOfStream;
-    protected InputStream in;
     
     protected ConnectionRecoveryManager conn;
     protected ResultSet rs;
@@ -54,6 +52,7 @@
      * @param identifier the data identifier
      */
     protected DbInputStream(DbDataStore store, DataIdentifier identifier) {
+        super(null);
         this.store = store;
         this.identifier = identifier;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java?rev=740262&r1=740261&r2=740262&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
Tue Feb  3 10:11:42 2009
@@ -26,14 +26,15 @@
 import java.io.OutputStream;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.AutoCloseInputStream;
 
 /**
- * An input stream from a temp file that self-destructs when fully read or closed.
+ * An input stream from a temporary file. The file is deleted when the stream is
+ * closed, fully read, or garbage collected.
  */
-public class TempFileInputStream extends InputStream {
+public class TempFileInputStream extends AutoCloseInputStream {
 
     private final File file;
-    private final InputStream in;
     private boolean closed;
 
     /**
@@ -59,8 +60,8 @@
      * @param file the temporary file
      */
     public TempFileInputStream(File file) throws FileNotFoundException {
+        super(new BufferedInputStream(new FileInputStream(file)));
         this.file = file;
-        in = new BufferedInputStream(new FileInputStream(file));
     }
 
     private int closeIfEOF(int read) throws IOException {



Mime
View raw message