Debugger seems to display wrong lines when stopping at breakpoint and incorrect stacktrace

Answered

Actually I have a problem that a database connection was opened from a line (according to the debugger) where it could not happen.

I ensured that the correct version of the code is used (from project and not from an external jar). I tried it inside the IDE and with remote debugging.

As you can see in the screenshot the debugger shows that toString() in CombinedPrimaryKeySimpleDatabaseDAO is called from line 56 in GetDocumentCommand. But line 56 doesn't call this method.

The method queryDatabaseProductName (which is my point of failure) ist instead called indirectly (there are several methods between) from line 63 in GetDocumentCommand.

Additionally, the debugger does not stop in the toString() method when there is a breakpoint (this is correct because this code is not really executed).

I am only able to see this (the snapshot) in the debugger because the method borrowObject cannot be executed (for testing I limited the pool to size 1) because the pool is already exhausted). Breakpoints also don't work in this case, e.g. in GenericObjectPool.

When I stop the debugger in line 62 of GetDocumentCommand (only reached when the pool is > 1) I can see in my (postgres) database that the connection is already opened which should open when line 63 is executed.

Additionally, when I disable all breakpoints and wait until the code is hanging in borrowObject, pause the debugger, the actual executed statement according to the debugger is line 63 which is correct. When I step through the breakpoints the database connection is already opened before reaching line 63.

To ensure that this is a problem of the IDE I did the same with eclipse, and everything worked as expected there (database connection opened from the correct line, debugger stopping appropriate ...).

This seems completely weird to me I don't have any idea what's going wrong here.

And no, I am not able to create simple example to reproduce this.

 

What could cause this behavior?

Eddie

PS:

Just as comment: I am using the debugger since several years, often heavily. And before switching to IntelliJ I did this for more than 10 years with eclipse. Usually I am teaching others how to use the debugger. Nevertheless I am still hoping that it's my fault.

I also showed this to some colleageous in search for an explanation and to ensure that I don't overlook something.

0
6 comments

Hi Eddie,

Would it be possible for you to provide a demo project where this can be reproduced?

0

Unfortunately not.

This is a large project using hadoop mapreduce, spring (among others for database connection), apache chains and a lot of other stuff.

I have no idea what must be part of the example to be able to reproduce it.

0

Hi, try to disable 'toString()' object view in Settings | Build, Execution, Deployment | Debugger | Data Views | Java:

My guess is that this toString call comes from there. Another sign is the "Collecting data..." badge in the variables list.

0

Just a short feedback: This seemed to help. I will investigate this further (with breakproints enabled and disabled) next week when I have more time (also looking for "collecting data" and give you a feedback.

Can you tell me why toString() for a class which is not used at that line is called here?

What do I miss when I disable toString()? Appropriate displays for variables in the debug view?

0

By default IDEA tries to evaluate and show toString result for all objects in the variables view (local variables, fields etc.). Eclipse does not do this as far as I know, that's probably why the problem was not visible there.

With toString object view disabled, all the variables would still be there, just no toString presentation for them.

0

I just did some tests. Disabling toString() solves my problem completely.

Thanks for the fast help,

Eddie

 

0

Please sign in to leave a comment.