Prevayler doesn't close journal streams
Célio <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <[email protected]> |
Howdy, Our system tries to delete journals and snapshot files in case of error during deserialization, but it fails to delete them under Windows because the files are locked. Looking at prevayler's source code, I noticed that the streams that read the journals are not being closed. I did two small changes in PersistentJournal.recoverPendingTransactions(): (1) closing the current journal's stream before proceeding to the next journal, and (2) closing the stream in case of an error during the loop. A patch is attached to this message, however it's a quick-and-dirty fix so I guess you will not want to use it. Feel free to discard it. Best wishes, Célio ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org
close-streams.patch
(text/x-patch, 996 B)
--- PersistentJournal.java 2005-01-16 16:17:40.000000000 -0200
+++ /home/celio/dev/lib/prevayler-2.3-FIX/src/org/prevayler/implementation/journal/PersistentJournal.java 2011-01-13 10:36:13.874683150 -0200
@@ -164,6 +164,7 @@
File journal = initialJournal;
DurableInputStream input = new DurableInputStream(journal, _monitor);
+ try {
while(true) {
try {
Chunk chunk = input.readChunk();
@@ -186,6 +187,7 @@
recoveringTransaction++;
} catch (EOFException eof) {
+ input.close();
File nextFile = _directory.journalFile(recoveringTransaction, _journalSuffix);
if (journal.equals(nextFile)) PrevaylerDirectory.renameUnusedFile(journal); //The first transaction in this log file is incomplete. We need to reuse this file name.
journal = nextFile;
@@ -193,6 +195,9 @@
input = new DurableInputStream(journal, _monitor);
}
}
+ } finally {
+ input.close();
+ }
return recoveringTransaction;
}