reactor-core/src/main/java/reactor/core/publisher/FluxIterable.java
@SuppressWarnings("unchecked")
	static <T> void subscribe(CoreSubscriber<? super T> s, Iterator<? extends T> it,
			@Nullable Runnable onClose) {
		//noinspection ConstantConditions
		if (it == null) {
			Operators.error(s, new NullPointerException("The iterator is null"));
			return;
		}

		boolean b;

		try {
			b = it.hasNext();
		}
		catch (Throwable e) {
			Operators.error(s, Operators.onOperatorError(e, s.currentContext()));
			if (onClose != null) {
				try {
					onClose.run();
				}
				catch (Throwable t) {
					Operators.onErrorDropped(t, s.currentContext());
				}
			}
			return;
		}
		if (!b) {
			Operators.complete(s);
			if (onClose != null) {
				try {
					onClose.run();
				}
				catch (Throwable t) {
					Operators.onErrorDropped(t, s.currentContext());
				}
			}
			return;
		}

		if (s instanceof ConditionalSubscriber) {
			s.onSubscribe(new IterableSubscriptionConditional<>((ConditionalSubscriber<? super T>) s,
					it, onClose));
		}
		else {
			s.onSubscribe(new IterableSubscription<>(s, it, onClose));
		}
	}
@SuppressWarnings("unchecked")
	static <T> void subscribe(CoreSubscriber<? super T> s, Iterator<? extends T> it,
			@Nullable Runnable onClose) {
		//noinspection ConstantConditions
		if (it == null) {
			Operators.error(s, new NullPointerException("The iterator is null"));
			return;
		}

		boolean b;

		try {
			b = it.hasNext();
		}
		catch (Throwable e) {
			Operators.error(s, Operators.onOperatorError(e, s.currentContext()));
			if (onClose != null) {
				try {
					onClose.run();
				}
				catch (Throwable t) {
					Operators.onErrorDropped(t, s.currentContext());
				}
			}
			return;
		}
		if (!b) {
			Operators.complete(s);
			if (onClose != null) {
				try {
					onClose.run();
				}
				catch (Throwable t) {
					Operators.onErrorDropped(t, s.currentContext());
				}
			}
			return;
		}

		if (s instanceof ConditionalSubscriber) {
			s.onSubscribe(new IterableSubscriptionConditional<>((ConditionalSubscriber<? super T>) s,
					it, onClose));
		}
		else {
			s.onSubscribe(new IterableSubscription<>(s, it, onClose));
		}
	}
@ SuppressWarnings ( "unchecked" ) static < T > void subscribe ( CoreSubscriber < ? super T > s , Iterator < ? extends T > it , @ Nullable Runnable onClose ) { //noinspection ConstantConditions if ( it == null ) { Operators . error ( s , new NullPointerException ( "The iterator is null" ) ) ; return ; } boolean b ; try { b = it . hasNext ( ) ; } catch ( Throwable e ) { Operators . error ( s , Operators . onOperatorError ( e , s . currentContext ( ) ) ) ; if ( onClose != null ) { try { onClose . run ( ) ; } catch ( Throwable t ) { Operators . onErrorDropped ( t , s . currentContext ( ) ) ; } } return ; } if ( ! b ) { Operators . complete ( s ) ; if ( onClose != null ) { try { onClose . run ( ) ; } catch ( Throwable t ) { Operators . onErrorDropped ( t , s . currentContext ( ) ) ; } } return ; } if ( s instanceof ConditionalSubscriber ) { s . onSubscribe ( new IterableSubscriptionConditional <> ( ( ConditionalSubscriber < ? super T > ) s , it , onClose ) ) ; } else { s . onSubscribe ( new IterableSubscription <> ( s , it , onClose ) ) ; } }
Common method to take an Iterator as a source of values.

@param s the subscriber to feed this iterator to
@param it the iterator to use as a source of values
@param onClose close handler to call once we're done with the iterator (provided it
is not null, this includes when the iteration errors or complete or the subscriber
is cancelled). Null to ignore.
Common method to take an Iterator as a source of values .