@Test public void supplierCrash() { TestSubscriber<Object> ts = new TestSubscriber<>(Long.MAX_VALUE); Single.defer(() -> { throw new IllegalArgumentException(); }) .subscribe(ts); ts.assertFailure(IllegalArgumentException.class); }
@Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Single<? extends T> publisher; try { publisher = Objects.requireNonNull(supplier.get(), "The supplier returned a null Flow.Publisher"); } catch (Throwable ex) { subscriber.onSubscribe(EmptySubscription.INSTANCE); subscriber.onError(ex); return; } publisher.subscribe(subscriber); }
SingleDefer extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Single<? extends T> publisher; try { publisher = Objects.requireNonNull(supplier.get(), "The supplier returned a null Flow.Publisher"); } catch (Throwable ex) { subscriber.onSubscribe(EmptySubscription.INSTANCE); subscriber.onError(ex); return; } publisher.subscribe(subscriber); } }
SingleDefer extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Single<? extends T> publisher; try { publisher = Objects.requireNonNull(supplier.get(), "The supplier returned a null Flow.Publisher"); } catch (Throwable ex) { subscriber.onSubscribe(EmptySubscription.INSTANCE); subscriber.onError(ex); return; } publisher.subscribe(subscriber); } SingleDefer(Supplier<? extends Single<? extends T>> supplier); }
SingleDefer extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Single<? extends T> publisher; try { publisher = Objects.requireNonNull(supplier.get(), "The supplier returned a null Flow.Publisher"); } catch (Throwable ex) { subscriber.onSubscribe(EmptySubscription.INSTANCE); subscriber.onError(ex); return; } publisher.subscribe(subscriber); } SingleDefer(Supplier<? extends Single<? extends T>> supplier); @Override void subscribe(Flow.Subscriber<? super T> subscriber); }
SingleDefer extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Single<? extends T> publisher; try { publisher = Objects.requireNonNull(supplier.get(), "The supplier returned a null Flow.Publisher"); } catch (Throwable ex) { subscriber.onSubscribe(EmptySubscription.INSTANCE); subscriber.onError(ex); return; } publisher.subscribe(subscriber); } SingleDefer(Supplier<? extends Single<? extends T>> supplier); @Override void subscribe(Flow.Subscriber<? super T> subscriber);  }