Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error being undetected by the SubscriberExceptionHandler #7728

Open
3 tasks done
Jiabao-Sun opened this issue Mar 19, 2025 · 2 comments
Open
3 tasks done

Error being undetected by the SubscriberExceptionHandler #7728

Jiabao-Sun opened this issue Mar 19, 2025 · 2 comments
Labels
P3 no SLO package=eventbus type=enhancement Make an existing feature better

Comments

@Jiabao-Sun
Copy link

API(s)

`com.google.common.eventbus.Subscriber#dispatchEvent`

How do you want it to be improved?

  final void dispatchEvent(final Object event) {
    executor.execute(
        new Runnable() {
          @Override
          public void run() {
            try {
              invokeSubscriberMethod(event);
            } catch (InvocationTargetException e) {
              bus.handleSubscriberException(e.getCause(), context(event));
            } catch(Throwable e) {
              bus.handleSubscriberException(e, context(event));
            }
          }
        });
  }

Why do we need it to be improved?

The Subscriber#dispatchEvent did not catch Throwable, resulting in the Error being undetected by the SubscriberExceptionHandler

Example

-

Current Behavior

Desired Behavior

Error can be detected by the SubscriberExceptionHandler

Concrete Use Cases

Checklist

@Jiabao-Sun Jiabao-Sun added the type=enhancement Make an existing feature better label Mar 19, 2025
@eamonnmcmanus
Copy link
Member

First, a disclaimer: we recommend against using this API.

Can you say a bit about what kind of Error you are seeing here? It's not one that is thrown by the @Subscribe method, since that would be wrapped in an InvocationTargetException and handled by the existing code. So presumably something like OutOfMemoryError or LinkageError. It's not obvious to me that catching and logging such an Error is the right thing to do.

@Jiabao-Sun
Copy link
Author

Thanks @eamonnmcmanus for the quick feedback. When encountering ERRORs such as StackOverflowError, losing the problem stack trace can make troubleshooting extremely difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 no SLO package=eventbus type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

2 participants