@Test
public void sampleWithSamplerSourceThrows() {

    PublishSubject<Integer> source = PublishSubject.create();
    PublishSubject<Integer> sampler = PublishSubject.create();
    Observable<Integer> m = source.sample(sampler);
    m.subscribe(observer2);
    source.onNext(1);
    source.onError(new RuntimeException("Forced failure!"));
    sampler.onNext(1);
    InOrder inOrder = inOrder(observer2);
    inOrder.verify(observer2, times(1)).onError(any(Throwable.class));
    verify(observer2, never()).onNext(any());
    verify(observer, never()).onCompleted();
}