java - Guava 事件总线 : don't catch RuntimeException

标签 java exception guava runtimeexception

我使用 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/

相关文章:

java - 有人可以解释为什么我不能向这个 ScrollView 添加额外的按钮吗?

java - 无法使用java的Runtime.getRuntime().exec()隐藏文件夹

java - 如何使用 JAXB 映射 XML 忽略命名空间?

c# - C# 函数是否有标准的 "never returns"属性?

php - 需要帮助解决 Elasticsearch 中的 fatal error 异常

java - 使用 Guava RateLimiter 类限制方法调用

guava - 缓存和计算图

java - Guava 表 : how to iterate over columns when height and width is not known and table is sparse

java - GWT 对象序列化

ios - 将对象添加到 NSArray 时程序崩溃