Catch fatal errors thrown by invoker units as well. Also only log the

stack trace if we're not going to rethrow the error.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2958 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-02-21 00:22:30 +00:00
parent 813e7b0d47
commit a26e460fd6
@@ -1,5 +1,5 @@
//
// $Id: PresentsDObjectMgr.java,v 1.40 2004/02/21 00:04:40 mdb Exp $
// $Id: PresentsDObjectMgr.java,v 1.41 2004/02/21 00:22:30 mdb Exp $
package com.threerings.presents.server;
@@ -188,6 +188,10 @@ public class PresentsDObjectMgr
} catch (Exception e) {
Log.warning("Execution unit failed [unit=" + unit + "].");
Log.logStackTrace(e);
} catch (OutOfMemoryError oome) {
handleFatalError(oome);
} catch (StackOverflowError soe) {
handleFatalError(soe);
}
} else if (unit instanceof CompoundEvent) {
@@ -324,16 +328,10 @@ public class PresentsDObjectMgr
Log.logStackTrace(e);
} catch (OutOfMemoryError oome) {
Log.logStackTrace(oome);
if (_fatalThrottle.throttleOp()) {
throw oome;
}
handleFatalError(oome);
} catch (StackOverflowError soe) {
Log.logStackTrace(soe);
if (_fatalThrottle.throttleOp()) {
throw soe;
}
handleFatalError(soe);
}
// track the number of events dispatched
@@ -341,6 +339,18 @@ public class PresentsDObjectMgr
return true;
}
/**
* Attempts to recover from fatal errors but rethrows if things are
* freaking out too frequently.
*/
protected void handleFatalError (Error error)
{
if (_fatalThrottle.throttleOp()) {
throw error;
}
Log.logStackTrace(error);
}
/**
* Requests that the dobjmgr shut itself down soon- you may
* want to try using {@link Invoker#shutdown} which will make sure that