我使用 guava 的 EventBus,不幸的是它捕获并记录了事件处理程序抛出 RuntimeException 时发生的 InvocationTargetException。我可以禁用此行为吗?
最佳答案
就目前而言,这是一个深思熟虑的决定,并在 EventBus 文档中进行了讨论:
Handlers should not, in general, throw. If they do, the EventBus will catch and log the exception. This is rarely the right solution for error handling and should not be relied upon; it is intended solely to help find problems during development.
替代解决方案是 being considered ,尽管我严重怀疑他们是否会进入第 12 版。
关于java - Guava 事件总线 : don't catch RuntimeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9233966/