@Test public void onNextThrowsCancelsUpstream() { PublishProcessor<Integer> pp = PublishProcessor.create(); final List<Throwable> errors = new ArrayList<Throwable>(); pp.subscribe(new Consumer<Integer>() { @Override public void accept(Integer v) throws Exception { throw new TestException(); } }, new Consumer<Throwable>() { @Override public void accept(Throwable e) throws Exception { errors.add(e); } }); assertTrue("No observers?!", pp.hasSubscribers()); assertTrue("Has errors already?!", errors.isEmpty()); pp.onNext(1); assertFalse("Has observers?!", pp.hasSubscribers()); assertFalse("No errors?!", errors.isEmpty()); assertTrue(errors.toString(), errors.get(0) instanceof TestException); }
@Override public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } }
LambdaSubscriber extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection { @Override public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } } }
LambdaSubscriber extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection { @Override public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } } LambdaSubscriber(Consumer<? super T> onNext, Consumer<? super Throwable> onError,
            Action onComplete,
            Consumer<? super Subscription> onSubscribe); }
LambdaSubscriber extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection { @Override public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } } LambdaSubscriber(Consumer<? super T> onNext, Consumer<? super Throwable> onError,
            Action onComplete,
            Consumer<? super Subscription> onSubscribe); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override void dispose(); @Override boolean isDisposed(); @Override void request(long n); @Override void cancel(); @Override boolean hasCustomOnError(); }
LambdaSubscriber extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection { @Override public void onNext(T t) { if (!isDisposed()) { try { onNext.accept(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); get().cancel(); onError(e); } } } LambdaSubscriber(Consumer<? super T> onNext, Consumer<? super Throwable> onError,
            Action onComplete,
            Consumer<? super Subscription> onSubscribe); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override void dispose(); @Override boolean isDisposed(); @Override void request(long n); @Override void cancel(); @Override boolean hasCustomOnError();  }