Given the following code, result.block() equals "xx", isError() == false, yet the boom error handler is ran, the stacktrace is shown, the promise is not completed. I would expect the result to be "ko".
What am I doing wrong ? block() Javadoc says
will return null if onComplete, T if onNext
public class RApp {
static final Logger LOG = LoggerFactory.getLogger(RApp.class);
public static void main(String[] args) {
MonoProcessor<String> texecute = MonoProcessor.create();
Mono<String> result = texecute.delaySubscription(Duration.ofSeconds(2))
.onErrorReturn("ko")
.doOnNext(s -> parse(s)
.doOnSuccess(p -> LOG.info("promise completed {}", p))
.doOnTerminate((z, e) -> LOG.info("term value: {} , {}", z, e))
.doOnError(t -> {
LOG.error("boom", t);
})
.subscribe());
texecute.onNext("xx");
LOG.info("...............;");
String block = result.block();
LOG.info("r={}", block);
boolean error = texecute.isError();
LOG.info(error ? "error" : "no error");
texecute.dispose();
}
public static Mono<String> parse(String s) {
System.out.println("parse s = " + s);
if (s.equals("xx")) {
return Mono.error(new Exception("no xx"));
}
return Mono.just(s);
}
}