greenrobot/EventBus · error · EventBusException
Invoking subscriber failed
Error message
Invoking subscriber failed
What it means
Thrown from handleSubscriberException when the EventBus was built with throwSubscriberException=true (EventBusBuilder.throwSubscriberException or EventBus.builder().throwSubscriberException()) and a subscriber method threw. Normally subscriber exceptions are logged and/or delivered as a SubscriberExceptionEvent to subscribers of that type; with the strict flag set, the original cause is rethrown wrapped in EventBusException('Invoking subscriber failed') so the posting thread crashes — a deliberate fail-fast mode for development.
Source
Thrown at EventBus/src/org/greenrobot/eventbus/EventBus.java:537
handleSubscriberException(subscription, event, e.getCause());
} catch (IllegalAccessException e) {
throw new IllegalStateException("Unexpected exception", e);
}
}
private void handleSubscriberException(Subscription subscription, Object event, Throwable cause) {
if (event instanceof SubscriberExceptionEvent) {
if (logSubscriberExceptions) {
// Don't send another SubscriberExceptionEvent to avoid infinite event recursion, just log
logger.log(Level.SEVERE, "SubscriberExceptionEvent subscriber " + subscription.subscriber.getClass()
+ " threw an exception", cause);
SubscriberExceptionEvent exEvent = (SubscriberExceptionEvent) event;
logger.log(Level.SEVERE, "Initial event " + exEvent.causingEvent + " caused exception in "
+ exEvent.causingSubscriber, exEvent.throwable);
}
} else {
if (throwSubscriberException) {
throw new EventBusException("Invoking subscriber failed", cause);
}
if (logSubscriberExceptions) {
logger.log(Level.SEVERE, "Could not dispatch event: " + event.getClass() + " to subscribing class "
+ subscription.subscriber.getClass(), cause);
}
if (sendSubscriberExceptionEvent) {
SubscriberExceptionEvent exEvent = new SubscriberExceptionEvent(this, cause, event,
subscription.subscriber);
post(exEvent);
}
}
}
/** For ThreadLocal, much faster to set (and get multiple values). */
final static class PostingThreadState {
final List<Object> eventQueue = new ArrayList<>();
boolean isPosting;
boolean isMainThread;View on GitHub (pinned to 0194926b3b)
Solutions
- Fix the root cause named in the wrapped cause of the EventBusException (read the full stack trace: getCause() is the subscriber's original exception)
- Keep throwSubscriberException enabled only in debug builds: EventBus.builder().throwSubscriberException(BuildConfig.DEBUG).installDefaultEventBus()
- For production, handle failures inside the subscriber itself, or subscribe to SubscriberExceptionEvent to centralize error handling
- Ensure the failing subscriber never receives events it cannot process (narrow its event type)
Example fix
// before
EventBus.builder().throwSubscriberException(true).installDefaultEventBus();
// any subscriber crash kills the posting thread in production
// after
EventBus.builder()
.throwSubscriberException(BuildConfig.DEBUG)
.installDefaultEventBus();
// and in code
@Subscribe
public void onEvent(SubscriberExceptionEvent ex) {
crashReporter.log(ex.throwable); // centralized handling
} Defensive patterns
Strategy: try-catch
Try / catch
try {
EventBus.getDefault().post(event);
} catch (EventBusException e) {
if ("Invoking subscriber failed".equals(e.getMessage())) {
Throwable subscriberError = e.getCause(); // original exception from the handler
errorHandler.report(subscriberError); // log/report, keep app alive
return;
}
throw e;
} Prevention
- Enable throwSubscriberException only in debug builds via BuildConfig.DEBUG
- Subscribe to SubscriberExceptionEvent for production error routing
- Wrap risky work inside subscriber bodies in their own try-catch
When it happens
Trigger: A @Subscribe method throwing any runtime exception (NPE, IllegalStateException, network error) while EventBus is configured with throwSubscriberException; the exception propagates out of post() on the posting thread, or out of the MAIN/BACKGROUND poster thread.
Common situations: Teams enabling throwSubscriberException in debug builds to surface swallowed errors; a subscriber doing I/O that intermittently fails; an exception thrown only for a specific event payload reaching production with the strict flag still enabled.
Related errors
- Default instance already exists. It may be only set once bef
- It looks like you are using EventBus on Android, make sure t
- Subscriber ${subscriber.getClass()} already registered to ev
- This method may only be called from inside event handling me
- Event may not be null
AI-assisted analysis of greenrobot/EventBus@0194926b3b (2026-08-14).
Data as JSON: /api/errors/cd32050b80666e8e.
Report an issue: GitHub.