Is Mono.doFinally sufficient to handle release/cleanup?

Viewed 110

I am trying to synchronize a resource with spring webClient:

this.semaphore.acquire()
webClient
    .post()
    .uri("/a")
    .bodyValue(payload)
    .retrieve()
    .bodyToMono(String.class)    
    // release
    .doFinally(st -> this.semaphore.release())
    .switchIfEmpty(Mono.just("a"))
    .onErrorResume(Exception.class, e -> Mono.empty())
    .doOnNext()
    .subscribe();

Is doFinally sufficient to handle the release? If not, what are the "escape" points?

0 Answers
Related