DataGenerator
DataGenerator copied to clipboard
Output Thread exception handling in DefaultDistributor
In our current implementation, any exceptions thrown by the outputThread in DefaultDistributor have no way of propagating to the parent thread. When the thread dies, the exception is lost.
We need some way to fail the main thread in this case, or somehow detect these errors.
There is no way since the run method of the Thread class does not report to the caller. The only way is to correctly report it through the logger as an error.
Let me know if you have other ideas.
Our thought was that we could add a catch to produceOutput's calls to the consumers. If an exception is caught, we could set a flag in the distributor and possibly also a message, then throw from the Distributor when the output thread is joined.
Is that missing something? I think the produceOutput function should be able to catch exceptions from its own code, right?
High-level question: How do we want to communicate errors to the user in general?
Let's solve this in the multithreaded distributor.
@mibrahim is taking a look.
Nil suggests a static logger in the producers might be sufficient (?)