Jochen Koegel wrote:
Hi,
runFinalizersOnExit is deprecated, but this should be no problem for most users....
However, I want to use HSQL with the JVM wonka, and in wonka this method is not implemented at all. Since just commmenting out is a bad idea, I substituted that thing with a shutdownhook. See patch
Any ideas or suggestions?
Cheers Jochen
------------------------------------------------------------------------
--- hsqldb-orig/src/org/hsqldb/LockFile.java Sat Feb 7 16:10:47 2004
+++ hsqldb/src/org/hsqldb/LockFile.java Tue Feb 24 17:35:36 2004
@@ -192,6 +192,7 @@
* And opaque reference to this object's heatbeat task.
*/
private Object timerTask;
+
/**
* Attempts to read the hearbeat timestamp from this object's lock file
@@ -814,7 +815,13 @@
if (locked) {
writeMagic();
startHeartbeat();
-
+ //substitute for runFinalizersOnExit + //the Thread will keep a reference to this LockFile Object,
+ // so it won't be gc'ed :-(((
+ //however, there won't be too many lockfiles around...
+ Runtime.getRuntime().addShutdownHook(new FinalHook(this));
+/* wonka does not have the deprecated runFinalizersOnExit(true)
+a shutdownhook should do the job instead.
try {
// attempt to ensure that tryRelease() gets called if/when
@@ -825,6 +832,7 @@
} catch (Exception e) {
trace(mn + e.toString());
}
+ */
} else {
try {
releaseImpl();
@@ -938,7 +946,25 @@
* if any, that it has on its lock file.
*/
protected void finalize() throws Throwable {
- trace("finalize(): calling tryRelease()");
+ trace("finalize(): calling tryRelease()");
tryRelease();
+
}
+
+ private class FinalHook extends Thread{
+ private LockFile lockFile;
+ private FinalHook(){};
+ public FinalHook(LockFile _lockFile){
+ lockFile=_lockFile;
+ }
+
+ public void run(){
+ lockFile.trace("finalize(): calling tryRelease()");
+ try{
+ lockFile.tryRelease(); }
+ catch(Throwable t){}//what to do now?
+ }
+
+
+ }
}
-- ICF: 703-934-3692 Cell: 703-944-9317
------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ hsqldb-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hsqldb-developers