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; package com.threerings.presents.server;
@@ -188,6 +188,10 @@ public class PresentsDObjectMgr
} catch (Exception e) { } catch (Exception e) {
Log.warning("Execution unit failed [unit=" + unit + "]."); Log.warning("Execution unit failed [unit=" + unit + "].");
Log.logStackTrace(e); Log.logStackTrace(e);
} catch (OutOfMemoryError oome) {
handleFatalError(oome);
} catch (StackOverflowError soe) {
handleFatalError(soe);
} }
} else if (unit instanceof CompoundEvent) { } else if (unit instanceof CompoundEvent) {
@@ -324,16 +328,10 @@ public class PresentsDObjectMgr
Log.logStackTrace(e); Log.logStackTrace(e);
} catch (OutOfMemoryError oome) { } catch (OutOfMemoryError oome) {
Log.logStackTrace(oome); handleFatalError(oome);
if (_fatalThrottle.throttleOp()) {
throw oome;
}
} catch (StackOverflowError soe) { } catch (StackOverflowError soe) {
Log.logStackTrace(soe); handleFatalError(soe);
if (_fatalThrottle.throttleOp()) {
throw soe;
}
} }
// track the number of events dispatched // track the number of events dispatched
@@ -341,6 +339,18 @@ public class PresentsDObjectMgr
return true; 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 * Requests that the dobjmgr shut itself down soon- you may
* want to try using {@link Invoker#shutdown} which will make sure that * want to try using {@link Invoker#shutdown} which will make sure that