And this is the correct behavior in your case. You create mono from one line of βheyβ that has no errors. If you try to debug, you will see that the method doOnTerminateis being called with a parameter e = null, and according to the documentation it is being called anyway successor error.
, :
public class FluxTest {
@Test
public void testIt() throws InterruptedException {
Scheduler single = Schedulers.single();
CountDownLatch latch = new CountDownLatch(1);
Mono.just("hey")
.map(this::mapWithException)
.subscribeOn(single)
.doOnError(e -> System.out.println("ERROR1: " + e.getMessage()))
.doOnTerminate((r, e) -> {
if (e != null) System.out.println("ERROR3: " + e.getMessage());
latch.countDown();
})
.subscribe(
it -> { throw new RuntimeException("Error for " + it); },
ex -> { System.out.println("ERROR2: " + ex.getMessage());}
);
latch.await();
}
private String mapWithException(String s) {
throw new RuntimeException();
}
}
ERROR1: null
ERROR3: null
ERROR2: null
, onError, mono failed, onTerminate, mono , - errorConsumer subscribe.