Skip to content

Commit 11374c2

Browse files
Fix toIterator Exception Handling
1 parent 4f1b09c commit 11374c2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

rxjava-core/src/main/java/rx/internal/operators/BlockingOperatorToIterator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void onCompleted() {
5555

5656
@Override
5757
public void onError(Throwable e) {
58-
// ignore
58+
notifications.offer(Notification.<T>createOnError(e));
5959
}
6060

6161
@Override

rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,18 @@ public void call(Subscriber<? super String> observer) {
6767
assertEquals(true, it.hasNext());
6868
it.next();
6969
}
70+
71+
@Test(expected = TestException.class)
72+
public void testExceptionThrownFromOnSubscribe() {
73+
Iterable<String> strings = Observable.create(new Observable.OnSubscribe<String>() {
74+
@Override
75+
public void call(Subscriber<? super String> subscriber) {
76+
throw new TestException("intentional");
77+
}
78+
}).toBlocking().toIterable();
79+
for (String string : strings) {
80+
// never reaches here
81+
System.out.println(string);
82+
}
83+
}
7084
}

0 commit comments

Comments
 (0)