I'm creating an Spring WebFlux / Reactor application with IntelliJ IDEA. The debugger of IDEA shows many useless lines like MonoDefer, MonoFlatMap, etc. Is there a way to trace the stacks easily?
Reactor debug mode IntelliJ IDEA is aware of the Reactor debug mode and shows the traceback to the failed operation on the Frame tab of the Debug tool window. Moreover, IntelliJ IDEA can enable the debug mode without any changes in your code, making the necessary calls as you run the debugging session.
Click the Run icon in the gutter, then select Modify Run Configuration. Enter arguments in the Program arguments field. Click the Run button near the main method. From the menu, select Debug.
In an asynchronous world, unfortunately stack traces lose a lot of their meaning. Here you see a stack that shows the operators making up the whole of the reactive chain (including the ones the Spring Framework uses on top of those you defined in your controller). The only problem is it shows where the chain was triggered (or "subscribed"), because the execution is lazy and that's the only path visible at runtime...
For errors and stack traces proper, there is a .checkpoint()
operator that you can use explicitly in a chain in order to capture information about the "assembly" (where the chain of operators is declared in your code), to provide a bit more context. It is then shown as part of the exception stack straces, as a suppressed exception.
It was also a bit too difficult for us to use the new async debugger feature of IntelliJ because the execution model doesn't provide a fixed pair of "scheduling site vs execution site": the Scheduler
abstraction used to switch threads in the middle of a sequence by operators like publishOn
and subscribeOn
implies arbitrary "execution sites" (an arbitrary ExecutorService
, a roll-your-own-thread-pool, a Thread
, ...).
I encourage you to read up on stack traces and debugging in the official reference documentation at http://projectreactor.io/docs/core/release/reference/#debugging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With