Attached patch 1a, which fixes the bug with a ShutdownException raised in ContextManager by avoiding to destroy the tx if the database is shut down. Also, if the transaction is being destroyed, catch ShutdownException in case someone shuts down the database under our feet. This is already done in the main processing loop if the worker thread detects that the daemon has been stopped.
Since the patch is so small and isolated, I committed it right away with revision 1076462.
The coming patch for
DERBY-5088 will be larger, so I'll need to run more tests before committing.