Description
This would automatically protect against bugs like https://github.com/code-review-checklists/java-concurrency#concurrent-assert, and, I think, in general, it's a saner way to keep the database in the state that there are no uncaught exceptions happening in the system which cause threads to die. At best, it creates some thread churn (which might be a performance issue), at worst, it masks some problems, grey failures.
This would require some change in Druid's default ThreadFactory
used for various executors: it needs to set up a special Druid's UncaughtExceptionHandler
which logs an error in production, but has a flag which allows forwarding the exception to test framework and ultimately fail the test. I don't know exactly how to do this, but this is definitely possible; e. g. it's done in this class in Awaitility library. Note that just rethrowing an exception and also using the Awaitility library itself (setting Awaitility.dontCatchUncaughtExceptions(false)
) would not do the trick, because Awaitility only sets a custom exception handler for threads which don't have it yet. We would need to do this, too, but it's not enough because we already have threads with a custom UncaughtExceptionHandler
.