incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r591471 - /incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
Date Fri, 02 Nov 2007 21:24:38 GMT
Author: ngn
Date: Fri Nov  2 14:24:37 2007
New Revision: 591471

URL: http://svn.apache.org/viewvc?rev=591471&view=rev
Log:
IBM JVM requires the RandomAccessFile to be closed (FTPSERVER-114). Patch by Magnus Grimsell,
thanks!

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java?rev=591471&r1=591470&r2=591471&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
(original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
Fri Nov  2 14:24:37 2007
@@ -311,10 +311,20 @@
         }
 
         // create output stream
-        RandomAccessFile raf = new RandomAccessFile(file, "rw");
+        final RandomAccessFile raf = new RandomAccessFile(file, "rw");
         raf.setLength(offset);
         raf.seek(offset);
-        return new FileOutputStream(raf.getFD());
+
+        // The IBM jre needs to have both the stream and the random access file
+        // objects closed to actually close the file
+        return new FileOutputStream(raf.getFD())
+        {
+            public void close() throws IOException
+            {
+                super.close();
+                raf.close();
+            }
+        };
     }
 
     /**
@@ -328,9 +338,19 @@
         }
 
         // move to the appropriate offset and create input stream
-        RandomAccessFile raf = new RandomAccessFile(file, "r");
+        final RandomAccessFile raf = new RandomAccessFile(file, "r");
         raf.seek(offset);
-        return new FileInputStream(raf.getFD());
+
+        // The IBM jre needs to have both the stream and the random access file
+        // objects closed to actually close the file
+        return new FileInputStream(raf.getFD())
+        {
+            public void close() throws IOException
+            {
+                super.close();
+                raf.close();
+            }
+        };
     }
 
     /**



Mime
View raw message