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

The following examples show how to use reactor.core.Exceptions#addThrowable() . 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: FluxCreate.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void error(Throwable t) {
	Objects.requireNonNull(t, "t is null in sink.error(t)");
	if (sink.isTerminated() || done) {
		Operators.onOperatorError(t, sink.currentContext());
		return;
	}
	if (Exceptions.addThrowable(ERROR, this, t)) {
		done = true;
		drain();
	}
	else {
		Context ctx = sink.currentContext();
		Operators.onDiscardQueueWithClear(mpscQueue, ctx, null);
		Operators.onOperatorError(t, ctx);
	}
}
 
Example 2
Source File: FluxConcatMap.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(Throwable t) {
	if (Exceptions.addThrowable(ERROR, this, t)) {
		inner.cancel();

		if (GUARD.getAndIncrement(this) == 0) {
			t = Exceptions.terminate(ERROR, this);
			if (t != TERMINATED) {
				actual.onError(t);
				Operators.onDiscardQueueWithClear(queue, this.ctx, null);
			}
		}
	}
	else {
		Operators.onErrorDropped(t, this.ctx);
	}
}
 
Example 3
Source File: DefaultStepVerifierBuilder.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
final boolean onSignalCount(Signal<T> actualSignal, SignalCountEvent<T> event) {
	if (unasserted >= event.count) {
		this.script.poll();
		unasserted -= event.count;
	}
	else {
		if (event.count != 0) {
			Optional<AssertionError> error =
					this.checkCountMismatch(event, actualSignal);

			if (error.isPresent()) {
				Exceptions.addThrowable(ERRORS, this, error.get());
				if(actualSignal.isOnError()) {
					// #55 ensure the onError is added as a suppressed to the AssertionError
					error.get().addSuppressed(actualSignal.getThrowable());
				}
				maybeCancel(actualSignal);
				this.completeLatch.countDown();
			}
		}
		return true;
	}
	return false;
}
 
Example 4
Source File: FluxBufferWhen.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
void boundaryError(Disposable boundary, Throwable ex) {
	Operators.terminate(S, this);
	subscribers.remove(boundary);
	if (Exceptions.addThrowable(ERRORS, this, ex)) {
		subscribers.dispose();
		Map<Long, BUFFER> bufs;
		synchronized (this) {
			bufs = buffers;
			buffers = null;
		}
		done = true;
		drain();
		if (bufs != null) {
			for (BUFFER buffer : bufs.values()) {
				Operators.onDiscardMultiple(buffer, this.ctx);
			}
		}
	}
	else {
		Operators.onErrorDropped(ex, this.ctx);
	}
}
 
Example 5
Source File: FluxConcatMap.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void innerError(Throwable e) {
	e = Operators.onNextInnerError(e, currentContext(), s);
	if(e != null) {
		if (Exceptions.addThrowable(ERROR, this, e)) {
			if (!veryEnd) {
				s.cancel();
				done = true;
			}
			active = false;
			drain();
		}
		else {
			Operators.onErrorDropped(e, actual.currentContext());
		}
	}
	else {
		active = false;
	}
}
 
Example 6
Source File: FluxCombineLatest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
void innerError(Throwable e) {

			if (Exceptions.addThrowable(ERROR, this, e)) {
				done = true;
				drain();
			}
			else {
				discardQueue(queue);
				Operators.onErrorDropped(e, actual.currentContext());
			}
		}
 
Example 7
Source File: FluxWindowBoundary.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
void boundaryError(Throwable e) {
	cancelMain();
	if (Exceptions.addThrowable(ERROR, this, e)) {
		drain();
	} else {
		Operators.onErrorDropped(e, actual.currentContext());
	}
}
 
Example 8
Source File: FluxFlattenIterable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	if (Exceptions.addThrowable(ERROR, this, t)) {
		done = true;
		drain(null);
	}
	else {
		Operators.onErrorDropped(t, actual.currentContext());
	}
}
 
Example 9
Source File: StrictSubscriber.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	done = true;
	if (Exceptions.addThrowable(ERROR, this, t)) {
		if (WIP.getAndIncrement(this) == 0) {
			actual.onError(Exceptions.terminate(ERROR, this));
		}
	}
	else {
		Operators.onErrorDropped(t, Context.empty());
	}
}
 
Example 10
Source File: FluxFlatMap.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	if (done) {
		Operators.onErrorDropped(t, actual.currentContext());
		return;
	}
	if (Exceptions.addThrowable(ERROR, this, t)) {
		done = true;
		drain(null);
	}
	else {
		Operators.onErrorDropped(t, actual.currentContext());
	}
}
 
Example 11
Source File: EmitterProcessor.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	Objects.requireNonNull(t, "onError");
	if (done) {
		Operators.onErrorDropped(t, currentContext());
		return;
	}
	if (Exceptions.addThrowable(ERROR, this, t)) {
		done = true;
		drain();
	}
	else {
		Operators.onErrorDroppedMulticast(t);
	}
}
 
Example 12
Source File: FluxJoin.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void innerError(Throwable ex) {
	if (Exceptions.addThrowable(ERROR, this, ex)) {
		ACTIVE.decrementAndGet(this);
		drain();
	}
	else {
		Operators.onErrorDropped(ex, actual.currentContext());
	}
}
 
Example 13
Source File: FluxZip.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
void error(Throwable e, int index) {
	if (Exceptions.addThrowable(ERROR, this, e)) {
		drain();
	}
	else {
		Operators.onErrorDropped(e, actual.currentContext());
	}
}
 
Example 14
Source File: FluxGroupBy.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	if (Exceptions.addThrowable(ERROR, this, t)) {
		done = true;
		drain();
	}
	else {
		Operators.onErrorDropped(t, actual.currentContext());
	}
}
 
Example 15
Source File: FluxMergeSequential.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
void innerError(MergeSequentialInner<R> inner, Throwable e) {
	if (Exceptions.addThrowable(ERROR, this, e)) {
		inner.setDone();
		if (errorMode != ErrorMode.END) {
			s.cancel();
		}
		drain();
	}
	else {
		Operators.onErrorDropped(e, actual.currentContext());
	}
}
 
Example 16
Source File: FluxConcatArray.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
	if (Exceptions.addThrowable(ERROR, this, t)) {
		onComplete();
	} else {
		Operators.onErrorDropped(t, actual.currentContext());
	}
}
 
Example 17
Source File: FluxCombineLatest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
void drainAsync() {
	final Queue<SourceAndArray> q = queue;

	int missed = 1;

	for (; ; ) {

		long r = requested;
		long e = 0L;

		while (e != r) {
			boolean d = done;

			SourceAndArray v = q.poll();

			boolean empty = v == null;

			if (checkTerminated(d, empty, q)) {
				return;
			}

			if (empty) {
				break;
			}

			R w;

			try {
				w = Objects.requireNonNull(combiner.apply(v.array), "Combiner returned null");
			}
			catch (Throwable ex) {
				Context ctx = actual.currentContext();
				Operators.onDiscardMultiple(Stream.of(v.array), ctx);

				ex = Operators.onOperatorError(this, ex,	v.array, ctx);
				Exceptions.addThrowable(ERROR, this, ex);
				//noinspection ConstantConditions
				ex = Exceptions.terminate(ERROR, this);
				actual.onError(ex);
				return;
			}

			actual.onNext(w);

			v.source.requestOne();

			e++;
		}

		if (e == r) {
			if (checkTerminated(done, q.isEmpty(), q)) {
				return;
			}
		}

		if (e != 0L && r != Long.MAX_VALUE) {
			REQUESTED.addAndGet(this, -e);
		}

		missed = WIP.addAndGet(this, -missed);
		if (missed == 0) {
			break;
		}
	}
}
 
Example 18
Source File: FluxExpand.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
void innerError(ExpandDepthSubscriber inner, Throwable t) {
	Exceptions.addThrowable(ERROR, this, t);
	inner.done = true;
	drainQueue();
}
 
Example 19
Source File: DefaultStepVerifierBuilder.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
final void setFailurePrefix(String prefix, Signal<T> actualSignal, String msg, Object... arguments) {
	Exceptions.addThrowable(ERRORS, this, messageFormatter.failPrefix(prefix, msg, arguments));
	maybeCancel(actualSignal);
	this.completeLatch.countDown();
}
 
Example 20
Source File: DefaultStepVerifierBuilder.java    From reactor-core with Apache License 2.0 2 votes vote down vote up
/**
 * Signal a failure, potentially cancelling this subscriber if the actual signal
 * is neither onComplete nor onError (for which cancel is prohibited).
 *
 * @param event the event that triggered the failure
 * @param actualSignal the actual signal that triggered the failure (used to
 * decide whether or not to cancel, passing null will cause cancellation)
 * @param msg the message for the error
 * @param arguments the optional formatter arguments to the message
 */
final void setFailure(@Nullable Event<T> event, @Nullable Signal<T> actualSignal, String msg, Object... arguments) {
	Exceptions.addThrowable(ERRORS, this, messageFormatter.fail(event, msg, arguments));
	maybeCancel(actualSignal);
	this.completeLatch.countDown();
}