How To Debug Java Streams Using Intellij Idea

Tanveer
3 min readJan 31, 2022

--

While Debugging you might have faced this problem with streams, how should I debug these streams, what’s wrong with this ? did you think why are you not able to debug streams like another set of lines of code?

Let’s understand why did you face this problem?

Stream is made up of Intermediate and terminal operations so without execution of the terminal operation, you can’t have the result and it does not return without terminal operation, so to combat with this IntelliJ provide a great feature/tool.

What do you need to debug the java streams?

You just need the Java Stream Debugger plugin in your IntelliJ, here is how can you install it,

Step1: Open Intellij

Step2: Click on file →Settings →Plugins

step3: Search for Java Stream Debugger and install it.

step4: Restart IntelliJ to apply the changes

Let’s Do some hands-on!

step1: I have written a few lines of code as below,

This is basic code which is having streams of string and I am performing filter operation for strings that start with “W” and then performing mapping operation followed by distinct operation(to remove the duplicate values), finally doing the sorting.

step2: Put debugger point,

step3: Run as debug and wait for the debugger to appear, and then click on Trace Current stream chain as shown below,

step4: Interface will be open something like this, you can navigate on differnt different tabs,

we are seeing in split mode,

If you want to see it in the flat mode you can change it by clicking on flat mode as below,

Thank you for reading hope it helped you, Happy Debugging :)

--

--

Tanveer

Java software Engineer | Spring (boot, cloud,MVC) | microservices | docker, kubernetes | Kafka, Elk