@Override public boolean test(Notification<Object> t) throws Exception { return t.isOnError(); } }
@Override public boolean test(Notification<Object> t) throws Exception { return t.isOnError(); } }
@Override protected void onDrop(Notification<T> n) { if (n.isOnError()) { RxJavaCommonPlugins.onError(n.getError()); } } }
@SuppressWarnings("rawtypes") static String kind(Notification notification) { if (notification.isOnError()) { return "OnError"; } if (notification.isOnNext()) { return "OnNext"; } return "OnComplete"; }
@SuppressWarnings("rawtypes") static String kind(Notification notification) { if (notification.isOnError()) { return "OnError"; } if (notification.isOnNext()) { return "OnNext"; } return "OnComplete"; }
@Override public boolean hasNext() { if (iteratorNotification != null && iteratorNotification.isOnError()) { throw ExceptionHelper.wrapOrThrow(iteratorNotification.getError()); } if (iteratorNotification == null) { try { BlockingHelper.verifyNonBlocking(); notify.acquire(); } catch (InterruptedException ex) { dispose(); iteratorNotification = Notification.createOnError(ex); throw ExceptionHelper.wrapOrThrow(ex); } Notification<T> n = value.getAndSet(null); iteratorNotification = n; if (n.isOnError()) { throw ExceptionHelper.wrapOrThrow(n.getError()); } } return iteratorNotification.isOnNext(); }
@Override public boolean hasNext() { if (iteratorNotification != null && iteratorNotification.isOnError()) { throw ExceptionHelper.wrapOrThrow(iteratorNotification.getError()); } if (iteratorNotification == null) { try { BlockingHelper.verifyNonBlocking(); notify.acquire(); } catch (InterruptedException ex) { dispose(); iteratorNotification = Notification.createOnError(ex); throw ExceptionHelper.wrapOrThrow(ex); } Notification<T> n = value.getAndSet(null); iteratorNotification = n; if (n.isOnError()) { throw ExceptionHelper.wrapOrThrow(n.getError()); } } return iteratorNotification.isOnNext(); }
@Override public boolean hasNext() { if (iteratorNotification != null && iteratorNotification.isOnError()) { throw ExceptionHelper.wrapOrThrow(iteratorNotification.getError()); } if (iteratorNotification == null || iteratorNotification.isOnNext()) { if (iteratorNotification == null) { try { BlockingHelper.verifyNonBlocking(); notify.acquire(); } catch (InterruptedException ex) { dispose(); iteratorNotification = Notification.createOnError(ex); throw ExceptionHelper.wrapOrThrow(ex); } Notification<T> n = value.getAndSet(null); iteratorNotification = n; if (n.isOnError()) { throw ExceptionHelper.wrapOrThrow(n.getError()); } } } return iteratorNotification.isOnNext(); }
return false; if (nextNotification.isOnError()) { error = nextNotification.getError(); throw ExceptionHelper.wrapOrThrow(error);
@Test public void testMaterialize1() { // null will cause onError to be triggered before "three" can be // returned final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null, "three"); TestLocalObserver observer = new TestLocalObserver(); Observable<Notification<String>> m = Observable.unsafeCreate(o1).materialize(); m.subscribe(observer); try { o1.t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } assertFalse(observer.onError); assertTrue(observer.onComplete); assertEquals(3, observer.notifications.size()); assertTrue(observer.notifications.get(0).isOnNext()); assertEquals("one", observer.notifications.get(0).getValue()); assertTrue(observer.notifications.get(1).isOnNext()); assertEquals("two", observer.notifications.get(1).getValue()); assertTrue(observer.notifications.get(2).isOnError()); assertEquals(NullPointerException.class, observer.notifications.get(2).getError().getClass()); }
@Test public void testMaterialize1() { // null will cause onError to be triggered before "three" can be // returned final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null, "three"); TestNotificationSubscriber observer = new TestNotificationSubscriber(); Flowable<Notification<String>> m = Flowable.unsafeCreate(o1).materialize(); m.subscribe(observer); try { o1.t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } assertFalse(observer.onError); assertTrue(observer.onComplete); assertEquals(3, observer.notifications.size()); assertTrue(observer.notifications.get(0).isOnNext()); assertEquals("one", observer.notifications.get(0).getValue()); assertTrue(observer.notifications.get(1).isOnNext()); assertEquals("two", observer.notifications.get(1).getValue()); assertTrue(observer.notifications.get(2).isOnError()); assertEquals(NullPointerException.class, observer.notifications.get(2).getError().getClass()); }
@Test public void testBackpressureWithEmissionThenError() { TestSubscriber<Notification<Integer>> ts = new TestSubscriber<Notification<Integer>>(0L); IllegalArgumentException ex = new IllegalArgumentException(); Flowable.fromIterable(Arrays.asList(1)).concatWith(Flowable.<Integer> error(ex)).materialize() .subscribe(ts); ts.assertNoValues(); ts.request(1); ts.assertValueCount(1); assertTrue(ts.values().get(0).isOnNext()); ts.request(1); ts.assertValueCount(2); assertTrue(ts.values().get(1).isOnError()); assertEquals(ex, ts.values().get(1).getError()); ts.assertComplete(); }