void fastPath() { final Iterator<? extends T> a = iterator; final Subscriber<? super T> s = actual; for (; ; ) { if (cancelled) { return; } T t; try { t = a.next(); } catch (Exception ex) { s.onError(ex); return; } if (cancelled) { return; } if (t == null) { s.onError(new NullPointerException("The iterator returned a null value")); return; } s.onNext(t); if (cancelled) { return; } boolean b; try { b = a.hasNext(); } catch (Exception ex) { s.onError(ex); return; } if (cancelled) { return; } if (!b) { s.onComplete(); return; } } }
@Override public void onError(Throwable t) { if (done) { RxJavaPlugins.onError(t); return; } done = true; actual.onError(t); }
@Override public void subscribe(Subscriber<? super String> observer) { observer.onSubscribe(EmptySubscription.INSTANCE); boolean errorThrown = false; for (String s : valuesToReturn) { if (s == null) { System.out.println("throwing exception"); observer.onError(new NullPointerException()); errorThrown = true; // purposefully not returning here so it will continue calling onNext // so that we also test that we handle bad sequences like this } else { observer.onNext(s); } } if (!errorThrown) { observer.onComplete(); } }
@Override public void onError(Throwable t) { if (done) { RxJavaPlugins.onError(t); return; } done = true; try { onError.accept(t); } catch (Throwable e) { t.addSuppressed(e); } actual.onError(t); try { onAfterTerminate.run(); } catch (Throwable e) { RxJavaPlugins.onError(e); } }
void slowPath(long n) { final Iterator<? extends T> a = iterator; final Subscriber<? super T> s = actual; long e = 0L; for (; ; ) { while (e != n) { T t; try { t = a.next(); } catch (Throwable ex) { s.onError(ex); return; } if (cancelled) { return; } if (t == null) { s.onError(new NullPointerException("The iterator returned a null value")); return; } s.onNext(t); if (cancelled) { return; } boolean b; try { b = a.hasNext(); } catch (Throwable ex) { s.onError(ex); return; } if (cancelled) { return; } if (!b) { s.onComplete(); return; } e++; } n = requested; if (n == e) { n = REQUESTED.addAndGet(this, -e); if (n == 0L) { return; } e = 0L; } } }