jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r769326 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: data/FileDataRecord.java data/LazyFileInputStream.java value/BLOBInTempFile.java
Date Tue, 28 Apr 2009 10:30:17 GMT
Author: thomasm
Date: Tue Apr 28 10:30:17 2009
New Revision: 769326

URL: http://svn.apache.org/viewvc?rev=769326&view=rev
Log:
JCR-2083 BLOB Store: only open a stream when really necessary

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataRecord.java?rev=769326&r1=769325&r2=769326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataRecord.java
Tue Apr 28 10:30:17 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.data;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 
 /**
@@ -52,7 +53,11 @@
      * {@inheritDoc}
      */
     public InputStream getStream() throws DataStoreException {
-        return new LazyFileInputStream(file);
+        try {
+            return new LazyFileInputStream(file);
+        } catch (IOException e) {
+            throw new DataStoreException("Error opening input stream of " + file.getAbsolutePath(),
e);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java?rev=769326&r1=769325&r2=769326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java
Tue Apr 28 10:30:17 2009
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.commons.io.input.AutoCloseInputStream;
@@ -51,8 +52,11 @@
      * 
      * @param file the file
      */
-    protected LazyFileInputStream(File file) {
+    public LazyFileInputStream(File file) throws FileNotFoundException {
         super(null);
+        if (!file.canRead()) {
+            throw new FileNotFoundException(file.getPath());
+        }        
         this.file = file;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java?rev=769326&r1=769325&r2=769326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
Tue Apr 28 10:30:17 2009
@@ -17,10 +17,10 @@
 package org.apache.jackrabbit.core.value;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.core.data.LazyFileInputStream;
 import org.apache.jackrabbit.util.TransientFileFactory;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -141,7 +141,7 @@
      */
     public InputStream getStream() throws IllegalStateException, RepositoryException {
         try {
-            return new FileInputStream(file);
+            return new LazyFileInputStream(file);
         } catch (FileNotFoundException fnfe) {
             throw new RepositoryException("file backing binary value not found", fnfe);
         }



Mime
View raw message