use of reactor.core.publisher.Sinks.EmitResult in project reactor-core by reactor.
the class NextProcessor method emitEmpty.
void emitEmpty(Sinks.EmitFailureHandler failureHandler) {
for (; ; ) {
Sinks.EmitResult emitResult = tryEmitValue(null);
if (emitResult.isSuccess()) {
return;
}
boolean shouldRetry = failureHandler.onEmitFailure(SignalType.ON_COMPLETE, emitResult);
if (shouldRetry) {
continue;
}
switch(emitResult) {
case FAIL_ZERO_SUBSCRIBER:
case FAIL_OVERFLOW:
case FAIL_CANCELLED:
case FAIL_TERMINATED:
return;
case FAIL_NON_SERIALIZED:
throw new EmissionException(emitResult, "Spec. Rule 1.3 - onSubscribe, onNext, onError and onComplete signaled to a Subscriber MUST be signaled serially.");
default:
throw new EmissionException(emitResult, "Unknown emitResult value");
}
}
}
use of reactor.core.publisher.Sinks.EmitResult in project reactor-core by reactor.
the class SinkOneMulticastTest method successDoOnTerminate.
@Test
void successDoOnTerminate() {
SinkOneMulticast<String> sink = new SinkOneMulticast<>();
AtomicInteger invoked = new AtomicInteger();
sink.doOnTerminate(invoked::incrementAndGet).subscribe();
EmitResult emitResult = sink.tryEmitValue("test");
assertThat(emitResult).isEqualTo(EmitResult.OK);
assertThat(invoked).hasValue(1);
assertThat(sink.scan(Scannable.Attr.ERROR)).isNull();
assertThat(sink.scan(Scannable.Attr.TERMINATED)).isTrue();
}
use of reactor.core.publisher.Sinks.EmitResult in project reactor-core by reactor.
the class SinkOneMulticastTest method successDoOnSuccess.
@Test
void successDoOnSuccess() {
SinkOneMulticast<String> sink = new SinkOneMulticast<>();
AtomicReference<String> ref = new AtomicReference<>();
sink.doOnSuccess(ref::set).subscribe();
EmitResult emitResult = sink.tryEmitValue("test");
assertThat(emitResult).isEqualTo(EmitResult.OK);
assertThat(ref.get()).isEqualToIgnoringCase("test");
assertThat(sink.scan(Scannable.Attr.ERROR)).isNull();
assertThat(sink.scan(Scannable.Attr.TERMINATED)).isTrue();
}
use of reactor.core.publisher.Sinks.EmitResult in project reactor-core by reactor.
the class SinkOneMulticastTest method rejectedDoOnError.
@Test
void rejectedDoOnError() {
SinkOneMulticast<String> sink = new SinkOneMulticast<>();
AtomicReference<Throwable> ref = new AtomicReference<>();
sink.doOnError(ref::set).subscribe(v -> {
}, e -> {
});
EmitResult emitResult = sink.tryEmitError(new Exception("test"));
assertThat(emitResult).isEqualTo(EmitResult.OK);
assertThat(ref.get()).hasMessage("test");
assertThat(sink.scan(Scannable.Attr.ERROR)).hasMessage("test");
assertThat(sink.scan(Scannable.Attr.TERMINATED)).isTrue();
}
use of reactor.core.publisher.Sinks.EmitResult in project reactor-core by reactor.
the class SinkOneMulticastTest method rejectedDoOnTerminate.
@Test
void rejectedDoOnTerminate() {
SinkOneMulticast<String> sink = new SinkOneMulticast<>();
AtomicInteger invoked = new AtomicInteger();
sink.doOnTerminate(invoked::incrementAndGet).subscribe(v -> {
}, e -> {
});
EmitResult emitResult = sink.tryEmitError(new Exception("test"));
assertThat(emitResult).isEqualTo(EmitResult.OK);
assertThat(invoked).hasValue(1);
assertThat(sink.scan(Scannable.Attr.ERROR)).hasMessage("test");
assertThat(sink.scan(Scannable.Attr.TERMINATED)).isTrue();
}
Aggregations