How to cancel the CompletableFuture owned by Mono.fromFuture(Supplier)?

The documentation for Mono.fromFuture(Supplier) says:

Note that the future is not cancelled when that Mono is cancelled, but that behavior can be obtained by using a doFinally(Consumer) that checks for a SignalType.CANCEL and calls CompletableFuture.cancel(boolean).

How do you get a reference to the future returned by the supplier?

public static <T> Mono<T> toMono(Supplier<CompletableFuture<T>> supplier) {
  return Mono.fromFuture(supplier)
      .doFinally(signal -> {
        if (signal == SignalType.CANCEL) {
          // ??????
        }
      })
}


Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)