directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r695820 - in /directory/apacheds/trunk: jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java jdbm/src/main/java/jdbm/recman/TransactionManager.java
Date Tue, 16 Sep 2008 11:55:39 GMT
Author: elecharny
Date: Tue Sep 16 04:55:38 2008
New Revision: 695820

URL: http://svn.apache.org/viewvc?rev=695820&view=rev
Log:
Applied Norval's patch to fix DIRSERVER-1255

Modified:
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TransactionManager.java

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=695820&r1=695819&r2=695820&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
Tue Sep 16 04:55:38 2008
@@ -75,11 +75,6 @@
         loader.loadWithDependencies( bootstrapSchemas, registries );
         this.registry = registries.getAttributeTypeRegistry();
 
-        if ( dbFileDir != null )
-        {
-            dbFileDir.delete();
-        }
-
         File tmpIndexFile = File.createTempFile( JdbmIndexTest.class.getSimpleName(), "db"
);
         tmpIndexFile.deleteOnExit();
         dbFileDir = new File( tmpIndexFile.getParentFile(),
@@ -108,8 +103,14 @@
         {
             idx.sync();
             idx.close();
-            File file = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
-            file.delete();
+            
+            // created by this test
+            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
+            assert dbFile.delete();
+            
+            // created by TransactionManager
+            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg"
);
+            assert logFile.delete();
         }
         
         idx = null;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TransactionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TransactionManager.java?rev=695820&r1=695819&r2=695820&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TransactionManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TransactionManager.java Tue Sep
16 04:55:38 2008
@@ -210,10 +210,13 @@
         ObjectInputStream ois = new ObjectInputStream(fis);
 
         try {
-            if (ois.readShort() != Magic.LOGFILE_HEADER)
+            if (ois.readShort() != Magic.LOGFILE_HEADER) {
+                ois.close();
                 throw new Error("Bad magic on log file");
+            }
         } catch (IOException e) {
             // corrupted/empty logfile
+            ois.close();
             logFile.delete();
             return;
         }
@@ -223,6 +226,7 @@
             try {
                 blocks = (ArrayList) ois.readObject();
             } catch (ClassNotFoundException e) {
+                ois.close();
                 throw new Error("Unexcepted exception: " + e);
             } catch (IOException e) {
                 // corrupted logfile, ignore rest of transactions
@@ -240,6 +244,7 @@
             }
         }
         owner.sync();
+        ois.close();
         logFile.delete();
     }
 
@@ -313,9 +318,10 @@
         // set clean flag to indicate blocks have been written to log
         setClean(txns[curTxn]);
 
-        // open a new ObjectOutputStream in order to store
+        // reset ObjectOutputStream in order to store
         // newer states of BlockIo
         oos = new ObjectOutputStream(fos);
+        oos.reset();
     }
 
     /** Flushes and syncs */



Mime
View raw message