@Test public void testDeferFunctionThrows() { Func0<Observable<String>> factory = mock(Func0.class); when(factory.call()).thenThrow(new TestException()); Observable<String> result = Observable.defer(factory); Observer<String> o = mock(Observer.class); result.subscribe(o); verify(o).onError(any(TestException.class)); verify(o, never()).onNext(any(String.class)); verify(o, never()).onCompleted(); }
@Override public void call(Subscriber<? super T> s) { Observable<? extends T> o; try { o = observableFactory.call(); } catch (Throwable t) { s.onError(t); return; } o.unsafeSubscribe(s); }
OnSubscribeDefer implements OnSubscribe<T> { @Override public void call(Subscriber<? super T> s) { Observable<? extends T> o; try { o = observableFactory.call(); } catch (Throwable t) { s.onError(t); return; } o.unsafeSubscribe(s); } }
OnSubscribeDefer implements OnSubscribe<T> { @Override public void call(Subscriber<? super T> s) { Observable<? extends T> o; try { o = observableFactory.call(); } catch (Throwable t) { s.onError(t); return; } o.unsafeSubscribe(s); } OnSubscribeDefer(Func0<? extends Observable<? extends T>> observableFactory); }
OnSubscribeDefer implements OnSubscribe<T> { @Override public void call(Subscriber<? super T> s) { Observable<? extends T> o; try { o = observableFactory.call(); } catch (Throwable t) { s.onError(t); return; } o.unsafeSubscribe(s); } OnSubscribeDefer(Func0<? extends Observable<? extends T>> observableFactory); @Override void call(Subscriber<? super T> s); }
OnSubscribeDefer implements OnSubscribe<T> { @Override public void call(Subscriber<? super T> s) { Observable<? extends T> o; try { o = observableFactory.call(); } catch (Throwable t) { s.onError(t); return; } o.unsafeSubscribe(s); } OnSubscribeDefer(Func0<? extends Observable<? extends T>> observableFactory); @Override void call(Subscriber<? super T> s);  }