jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r745847 - /jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java
Date Thu, 19 Feb 2009 13:00:39 GMT
Author: mreutegg
Date: Thu Feb 19 13:00:39 2009
New Revision: 745847

URL: http://svn.apache.org/viewvc?rev=745847&view=rev
Log:
Call close at most once.

Modified:
    jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java

Modified: jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java?rev=745847&r1=745846&r2=745847&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java
(original)
+++ jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java
Thu Feb 19 13:00:39 2009
@@ -18,6 +18,7 @@
 
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.FilterInputStream;
 
 import org.apache.jackrabbit.core.data.AbstractDataRecord;
 import org.apache.jackrabbit.core.data.DataStoreException;
@@ -50,7 +51,22 @@
 
     public InputStream getStream() throws DataStoreException {
         try {
-            return fs.open(path);
+            // make sure close is only called once, otherwise HDFS complains
+            // and throws an IOException :-/
+            return new FilterInputStream(fs.open(path)) {
+
+                boolean closed = false;
+
+                public void close() throws IOException {
+                    if (!closed) {
+                        try {
+                            super.close();
+                        } finally {
+                            closed = true;
+                        }
+                    }
+                }
+            };
         } catch (IOException e) {
             throw new DataStoreException(e);
         }



Mime
View raw message