|
15 | 15 | */ |
16 | 16 | package rx.internal.operators; |
17 | 17 |
|
| 18 | +import static org.junit.Assert.assertEquals; |
| 19 | +import static org.junit.Assert.assertFalse; |
| 20 | +import static org.junit.Assert.assertTrue; |
| 21 | + |
18 | 22 | import java.util.concurrent.CountDownLatch; |
19 | 23 | import java.util.concurrent.TimeUnit; |
| 24 | +import java.util.concurrent.atomic.AtomicBoolean; |
20 | 25 |
|
21 | 26 | import org.junit.Test; |
| 27 | +import org.mockito.Mock; |
| 28 | +import org.mockito.Mockito; |
22 | 29 |
|
23 | 30 | import rx.Observable; |
24 | 31 | import rx.Observable.OnSubscribe; |
|
27 | 34 | import rx.Subscription; |
28 | 35 | import rx.exceptions.MissingBackpressureException; |
29 | 36 | import rx.functions.Action0; |
| 37 | +import rx.functions.Action1; |
30 | 38 | import rx.observers.TestSubscriber; |
31 | 39 | import rx.schedulers.Schedulers; |
32 | 40 |
|
33 | | -import static org.junit.Assert.assertEquals; |
34 | | -import static org.junit.Assert.assertTrue; |
35 | | - |
36 | 41 | public class OperatorOnBackpressureBufferTest { |
37 | 42 |
|
38 | 43 | @Test |
@@ -147,5 +152,30 @@ public void call(Subscriber<? super Long> s) { |
147 | 152 | } |
148 | 153 |
|
149 | 154 | }); |
| 155 | + |
| 156 | + private static final Action0 THROWS_NON_FATAL = new Action0() { |
| 157 | + |
| 158 | + @Override |
| 159 | + public void call() { |
| 160 | + throw new RuntimeException(); |
| 161 | + }}; |
| 162 | + |
| 163 | + @Test |
| 164 | + public void testNonFatalExceptionThrownByOnOverflowIsNotReportedByUpstream() { |
| 165 | + final AtomicBoolean errorOccurred = new AtomicBoolean(false); |
| 166 | + TestSubscriber<Long> ts = TestSubscriber.create(0); |
| 167 | + infinite |
| 168 | + .subscribeOn(Schedulers.computation()) |
| 169 | + .doOnError(new Action1<Throwable>() { |
| 170 | + @Override |
| 171 | + public void call(Throwable t) { |
| 172 | + errorOccurred.set(true); |
| 173 | + } |
| 174 | + }) |
| 175 | + .onBackpressureBuffer(1, THROWS_NON_FATAL) |
| 176 | + .subscribe(ts); |
| 177 | + ts.awaitTerminalEvent(); |
| 178 | + assertFalse(errorOccurred.get()); |
| 179 | + } |
150 | 180 |
|
151 | 181 | } |
0 commit comments