public void enqueue(Subscription subscription, Object event) { PendingPost pendingPost = PendingPost.obtainPendingPost(subscription, event); synchronized (this) { queue.enqueue(pendingPost); if (!handlerActive) { handlerActive = true; if (!sendMessage(obtainMessage())) { throw new EventBusException("Could not send handler message"); } } } }
@Subscribe public void onEvent(String event) { trackEvent(event); } };
@Subscribe public void onGenericEvent(GenericEvent<T> event) { trackEvent(event); } }
@Test public void testDoNotSendSubscriberExceptionEvent() { eventBus = EventBus.builder().logSubscriberExceptions(false).sendSubscriberExceptionEvent(false).build(); eventBus.register(new SubscriberExceptionEventTracker()); eventBus.register(new ThrowingSubscriber()); eventBus.post("Foo"); assertEventCount(0); }
@Test public void testBadExceptionSubscriber() { eventBus = EventBus.builder().logSubscriberExceptions(false).build(); eventBus.register(this); eventBus.register(new BadExceptionSubscriber()); eventBus.post("Foo"); assertEventCount(1); }
@Subscribe public void onEvent(SubscriberExceptionEvent event) { trackEvent(event); } }
@Override @Subscribe public void onEvent(String event) { trackEvent(event); }
@Subscribe public void onEvent(IntTestEvent event) { trackEvent(event); } }
@Subscribe public void onEvent(String event) { try { eventBus.cancelEventDelivery(this); } catch (EventBusException e) { failed = e; } } }
private void handleEvent(String event, int prio) { if(this.prio == prio) { trackEvent(event); if (cancel) { eventBus.cancelEventDelivery(event); } } } }
@Test public void testDoNotSendSubscriberExceptionEvent() { eventBus = EventBus.builder().logSubscriberExceptions(false).sendSubscriberExceptionEvent(false).build(); eventBus.register(new SubscriberExceptionEventTracker()); eventBus.register(new ThrowingSubscriber()); eventBus.post("Foo"); assertEventCount(0); }
@Subscribe public void onEvent(PrivateEvent any) { trackEvent(any); } }
@Subscribe public void onGenericEvent(T event) { trackEvent(event); } }
@Subscribe public void onEvent(SubscriberExceptionEvent event) { trackEvent(event); } }
@Subscribe public void onEvent(Object any) { trackEvent(any); } }
@Subscribe public void onEvent(String any) { trackEvent(any); } }
@Subscribe public void onEvent(PrivateEvent any) { trackEvent(any); } }
@Subscribe public void onEvent(Object any) { trackEvent(any); } }
@Subscribe public void onEvent(String event) { trackEvent(event); } };
@Subscribe public void onEvent(PrivateEvent any) { trackEvent(any); } }