Java Code Examples for reactor.core.Exceptions#multiple()

The following examples show how to use reactor.core.Exceptions#multiple() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonoWhen.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
void signal() {
	WhenInner[] a = subscribers;
	int n = a.length;
	if (DONE.incrementAndGet(this) != n) {
		return;
	}

	Throwable error = null;
	Throwable compositeError = null;

	for (int i = 0; i < a.length; i++) {
		WhenInner m = a[i];
		Throwable e = m.error;
		if (e != null) {
			if (compositeError != null) {
				//this is ok as the composite created below is never a singleton
				compositeError.addSuppressed(e);
			}
			else if (error != null) {
				compositeError = Exceptions.multiple(error, e);
			}
			else {
				error = e;
			}
		}

	}

	if (compositeError != null) {
		actual.onError(compositeError);
	}
	else if (error != null) {
		actual.onError(error);
	}
	else {
		actual.onComplete();
	}
}
 
Example 2
Source File: MonoDelayUntil.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
void signal() {
	int nextIndex = DONE.incrementAndGet(this);
	if (nextIndex != n) {
		subscribeNextTrigger(this.value, nextIndex);
		return;
	}

	Throwable error = null;
	Throwable compositeError = null;

	//check for errors in the triggers
	for (int i = 0; i < n; i++) {
		DelayUntilTrigger mt = triggerSubscribers[i];
		Throwable e = mt.error;
		if (e != null) {
			if (compositeError != null) {
				//this is ok as the composite created by multiple is never a singleton
				compositeError.addSuppressed(e);
			} else
			if (error != null) {
				compositeError = Exceptions.multiple(error, e);
			} else {
				error = e;
			}
			//else the trigger publisher was empty, but we'll ignore that
		}
	}

	if (compositeError != null) {
		actual.onError(compositeError);
	}
	else if (error != null) {
		actual.onError(error);
	} else {
		//emit the value downstream
		complete(this.value);
	}
}
 
Example 3
Source File: MonoZip.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
void signal() {
	ZipInner<R>[] a = subscribers;
	int n = a.length;
	if (DONE.incrementAndGet(this) != n) {
		return;
	}

	Object[] o = new Object[n];
	Throwable error = null;
	Throwable compositeError = null;
	boolean hasEmpty = false;

	for (int i = 0; i < a.length; i++) {
		ZipInner<R> m = a[i];
		Object v = m.value;
		if (v != null) {
			o[i] = v;
		}
		else {
			Throwable e = m.error;
			if (e != null) {
				if (compositeError != null) {
					//this is ok as the composite created below is never a singleton
					compositeError.addSuppressed(e);
				}
				else if (error != null) {
					compositeError = Exceptions.multiple(error, e);
				}
				else {
					error = e;
				}
			}
			else {
				hasEmpty = true;
			}
		}
	}

	if (compositeError != null) {
		actual.onError(compositeError);
	}
	else if (error != null) {
		actual.onError(error);
	}
	else if (hasEmpty) {
		actual.onComplete();
	}
	else {
		R r;
		try {
			r = Objects.requireNonNull(zipper.apply(o),
					"zipper produced a null value");
		}
		catch (Throwable t) {
			actual.onError(Operators.onOperatorError(null,
					t,
					o,
					actual.currentContext()));
			return;
		}
		complete(r);
	}
}