Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert mono to object java without using block()/blockFirst()/blockLast()

I want to convert mono to object java without using block()/blockFirst()/blockLast(). Please tell me the way to convert it.

like image 442
Dillip Kumar Avatar asked Oct 18 '25 11:10

Dillip Kumar


1 Answers

The official path is block(), which should serve as a warning that you may be doing something wrong, because blocking a non-blocking system is like shooting yourself in the foot.

In fact so much so that we recently forbid to do so on some of the non-blocking Schedulers of Reactor by throwing an exception when using these APIs:

java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-1

If you really like to shoot yourself in the foot, there is always the antipattern solution of .toFuture().get()... ¯\_(ツ)_/¯

like image 199
Simon Baslé Avatar answered Oct 21 '25 00:10

Simon Baslé



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!