@Test
  public void errorTest() throws InterruptedException {
    AVar<Throwable> caught = new AVar<>();
    Dispatcher asyncDispatcher = new ThreadPoolExecutorDispatcher(2, 100);
    Firehose<Key, Integer> asyncFirehose =
        new Firehose<>(asyncDispatcher, consumerRegistry, null, throwable -> caught.set(throwable));
    Key k1 = Key.wrap("key1");

    asyncFirehose.on(
        k1,
        (i) -> {
          int j = i / 0;
        });

    asyncFirehose.notify(k1, 1);

    assertTrue(caught.get(1, TimeUnit.MINUTES) instanceof ArithmeticException);

    asyncDispatcher.shutdown();
  }
Exemple #2
0
 private void supplyValue(final Subscriber<? super T> subscriber) {
   dispatcher.execute(
       new Runnable() {
         @Override
         public void run() {
           T supplied = supplier.get();
           if (supplied != null) {
             subscriber.onNext(supplied);
           } else {
             subscriber.onComplete();
           }
         }
       });
 }