Debug/running non-stop server

Asked

Viewed 336 times

1

It is possible to stop an execution that is in debug at the time of breakpoint without stopping the server?

I don’t want the debug continue because I know you’re wrong, for example I want you to stop before giving a Insert at the bank, that I can only stop the server.

1 answer

2

This nay is a feature present in the IDE or JVM, but there are some techniques that can be used in practice.

Comment on the code

While in debug mode, stopped at breakpoint, comment the lines you do not want to run and save the class.

As long as you do not change the class attribute declaration or method signatures, Eclipse will recompile the class and inject the new version into the JVM.

breakpoint should go back to the first line of the method and you can run it without affecting the database.

It doesn’t always work that directly. I haven’t figured out the exact reason yet, but some systems I’ve worked on the WTP Servers plugin simply restarts the application whenever a class is saved. But at least the code is not executed.

Change the code

When debugging any code, you may notice some "mistake". Instead of stopping the execution, you can simply fix the error and save the class.

The result is equivalent to what I explained in the previous topic.

Modify the variables

To test certain difficult to reproduce scenarios there is a very simple technique: modify the variables in the view variables of the Eclipse.

Suppose the result of the expression of a if always returns true to the implemented test scenarios and the effort to generate a false value is great.

In that case you can put a breakpoint on the line if and change the value of the variables in order to force the input to else.

The same principle can be applied to some code with which you are having difficulties in Ester.

For example:

boolean entra = true;
if (entra) inserirRegistro();

In the above example, just modify the value of the variable entra for false in the Eclipse, while maintaining the breakpoint standing on the line of if, to then not have the record entered.

Obviously, just use this for testing and remove unnecessary code after fixing the issue.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.