Fabian Zeindl Fabian Zeindl - 1 year ago 111
Java Question

Guava EventBus: don't catch RuntimeException

I use guava's EventBus, unfortunately it catches and logs the InvocationTargetException that occurs when an event-handler throws a RuntimeException. Can i disable this behaviour?

Answer Source

As it stands, this is a deliberate decision, and discussed in the EventBus docs:

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.

Alternative solutions are being considered, though I seriously doubt they'll make it into release 12.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download