@Override public void subscribe(CoreSubscriber<? super R> actual) { Iterator<? extends U> it; try { it = Objects.requireNonNull(other.iterator(), "The other iterable produced a null iterator"); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } boolean b; try { b = it.hasNext(); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } if (!b) { Operators.complete(actual); return; } source.subscribe(new ZipSubscriber<>(actual, it, zipper)); }
@Test public void scanSingleSubscriber() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxZipIterable.ZipSubscriber<Integer, Integer, Integer> test = new FluxZipIterable.ZipSubscriber<>(actual, new ArrayList<Integer>().iterator(), (i, j) -> i + j); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onComplete(); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
@Override public void subscribe(CoreSubscriber<? super R> actual) { Iterator<? extends U> it; try { it = Objects.requireNonNull(other.iterator(), "The other iterable produced a null iterator"); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } boolean b; try { b = it.hasNext(); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, actual.currentContext())); return; } if (!b) { Operators.complete(actual); return; } source.subscribe(new ZipSubscriber<>(actual, it, zipper)); }