* as long as there is work to do. When the queue is exhausted, the method
* will exit (the thread dies).
*/
public void run() {
final long runStart = System.currentTimeMillis();
ContextService ctxService = null;
// Implement the outer-level exception handling here.
try {
// DERBY-5088: Factory-call may fail.
ctxService = ContextService.getFactory();
ctxService.setCurrentContextManager(ctxMgr);
processingLoop();
} catch (ShutdownException se) {
// The database is/has been shut down.
// Log processing statistics and exit.
trace(1, "swallowed shutdown exception: " + extractIstatInfo(se));
stop();
ctxMgr.cleanupOnError(se, db.isActive());
} catch (RuntimeException re) {
// DERBY-4037
// Extended filtering of runtime exceptions during shutdown:
// o assertions raised by debug jars
// o runtime exceptions, like NPEs, raised by production jars -
// happens because the background thread interacts with store
// on a lower level
if (!isShuttingDown()) {
log(AS_BACKGROUND_TASK, null, re,
"runtime exception during normal operation");
throw re;
}
trace(1, "swallowed runtime exception during shutdown: " +
extractIstatInfo(re));
} finally {
if (ctxService != null) {
ctxService.resetCurrentContextManager(ctxMgr);
}
runTime += (System.currentTimeMillis() - runStart);
trace(0, "worker thread exit");
}
}