Closed
Description
The take
operator from pull request #212 and merged in #215 does not handle Observer.onNext
throwing exceptions.
This unit test reveals it:
@Test
public void testTakeWithErrorInObserver() {
final AtomicInteger count = new AtomicInteger();
final AtomicReference<Exception> error = new AtomicReference<Exception>();
Observable.from("1", "2", "three", "4").take(3).subscribe(new Observer<String>() {
@Override
public void onCompleted() {
System.out.println("completed");
}
@Override
public void onError(Exception e) {
error.set(e);
System.out.println("error");
e.printStackTrace();
}
@Override
public void onNext(String v) {
int num = Integer.parseInt(v);
System.out.println(num);
// doSomething(num);
count.incrementAndGet();
}
});
assertEquals(2, count.get());
assertNotNull(error.get());
if (!(error.get() instanceof NumberFormatException)) {
fail("It should be a NumberFormatException");
}
}
It silently fails with a count of 2 and never prints an exception or throws anything.
Metadata
Metadata
Assignees
Labels
No labels