directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1001339 - /directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
Date Sun, 26 Sep 2010 01:55:59 GMT
Author: seelmann
Date: Sun Sep 26 01:55:58 2010
New Revision: 1001339

URL: http://svn.apache.org/viewvc?rev=1001339&view=rev
Log:
Temporary fix to close RandomAccessFile and FileChannel, has to be moved to finally block

Modified:
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1001339&r1=1001338&r2=1001339&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
Sun Sep 26 01:55:58 2010
@@ -480,6 +480,7 @@ public class SingleFileLdifPartition ext
                 tempBuf.transferTo( 0, tempBuf.size(), mainChannel );
                 tempBuf.truncate( 0 );
                 tempBuf.close();
+                tmpMovFile.close();
                 tmpFile.delete();
 
                 // change offset of the copied entries
@@ -539,7 +540,8 @@ public class SingleFileLdifPartition ext
                 }
                 else
                 {
-                    FileChannel tmpBufChannel = createTempBuf();
+                    RandomAccessFile tempBufFile = createTempFile();
+                    FileChannel tmpBufChannel = tempBufFile.getChannel();
                     FileChannel mainChannel = ldifFile.getChannel();
 
                     long count = ( ldifFile.length() - entryOffset.getEnd() );
@@ -558,6 +560,8 @@ public class SingleFileLdifPartition ext
 
                     tmpBufChannel.transferTo( 0, tmpBufChannel.size(), mainChannel );
                     tmpBufChannel.truncate( 0 );
+                    tmpBufChannel.close();
+                    tempBufFile.close();
                     deleteTempFiles();
                 }
             }
@@ -731,7 +735,8 @@ public class SingleFileLdifPartition ext
 
             try
             {
-                FileChannel tmpBufChannel = createTempBuf();
+                RandomAccessFile tempBufFile = createTempFile();
+                FileChannel tmpBufChannel = tempBufFile.getChannel();
                 FileChannel mainChannel = ldifFile.getChannel();
 
                 long count = ( ldifFile.length() - aboveEntryOffset.getEnd() );
@@ -753,7 +758,7 @@ public class SingleFileLdifPartition ext
                 tmpBufChannel.transferTo( 0, tmpBufChannel.size(), mainChannel );
                 tmpBufChannel.truncate( 0 );
                 tmpBufChannel.close();
-                
+                tempBufFile.close();
                 deleteTempFiles();
             }
             catch ( IOException e )
@@ -812,7 +817,8 @@ public class SingleFileLdifPartition ext
                 */
                 // modified entry size got changed and is in the middle somewhere
                 {
-                    FileChannel tmpBufChannel = createTempBuf();
+                    RandomAccessFile tempBufFile = createTempFile();
+                    FileChannel tmpBufChannel = tempBufFile.getChannel();
                     FileChannel mainChannel = ldifFile.getChannel();
 
                     long count = ( ldifFile.length() - entryOffset.getEnd() );
@@ -832,7 +838,7 @@ public class SingleFileLdifPartition ext
                     tmpBufChannel.transferTo( 0, tmpBufChannel.size(), mainChannel );
                     tmpBufChannel.truncate( 0 );
                     tmpBufChannel.close();
-                    
+                    tempBufFile.close();
                     deleteTempFiles();
                 }
             }
@@ -1015,7 +1021,7 @@ public class SingleFileLdifPartition ext
 
 
     /** a temporary file used for swapping contents while performing update operations */
-    private FileChannel createTempBuf() throws IOException
+    private RandomAccessFile createTempFile() throws IOException
     {
         synchronized ( lock )
         {
@@ -1024,7 +1030,7 @@ public class SingleFileLdifPartition ext
             RandomAccessFile tempBufFile = new RandomAccessFile( tmpFile.getAbsolutePath(),
"rws" );
             tempBufFile.setLength( 0 );
 
-            return tempBufFile.getChannel();
+            return tempBufFile;
         }
     }
 



Mime
View raw message