Интересно, почему сигнал отмены обрабатывается не так, как другие.Кто-нибудь знает, является ли это преднамеренным?
Scheduler scheduler = Schedulers.elastic();
Disposable disposable =
Flux.interval(Duration.ofSeconds(1))
.publishOn(scheduler)
.doFinally(signalType -> {
if (signalType == SignalType.CANCEL) {
// caller thread - why ??
} else {
// elastic thread
}
}).log()
.subscribe();
Например,
Mono.just(1)
.delayElement(Duration.ofSeconds(3))
.doFinally(signalType -> {
disposable.dispose();
})
.subscribe();
производит вывод:
14:37:36.308 [main] INFO reactor.Flux.DoFinallyFuseable.1 - | onSubscribe([Fuseable] FluxDoFinally.DoFinallyFuseableSubscriber)
14:37:36.308 [main] INFO reactor.Flux.DoFinallyFuseable.1 - | request(unbounded)
14:37:37.324 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(0)
14:37:38.324 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(1)
14:37:39.325 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(2)
14:37:39.387 [parallel-2] INFO reactor.Flux.DoFinallyFuseable.1 - | cancel()
И
Thread.sleep(4000);
disposable.dispose();
производитвывод:
14:39:22.380 [main] INFO reactor.Flux.DoFinallyFuseable.1 - | onSubscribe([Fuseable] FluxDoFinally.DoFinallyFuseableSubscriber)
14:39:22.380 [main] INFO reactor.Flux.DoFinallyFuseable.1 - | request(unbounded)
14:39:23.412 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(0)
14:39:24.412 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(1)
14:39:25.414 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(2)
14:39:26.400 [elastic-2] INFO reactor.Flux.DoFinallyFuseable.1 - | onNext(3)
14:39:26.400 [main] INFO reactor.Flux.DoFinallyFuseable.1 - | cancel()