Debug / run non-stop server

1

Is it possible to stop an execution that is at debug at the moment of the breakpoint without stopping the server?

I do not want debug to continue because I know it is wrong, for example I want it to stop before giving an insert in the database, so I can only stop the server.

    
asked by anonymous 01.10.2014 / 03:03

1 answer

2

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

Comment the code

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

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

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

It does not always work so directly. I have not figured out the exact reason yet, but some systems on which I have already worked on the WTP Servers plugin simply restarts the application whenever a class is saved. But at least the code does not run.

Change the code

When debugging any code, you may notice some "mistake". Instead of stopping 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-play scenarios, there is a very simple technique: modifying the variables in Eclipse's variable view.

Suppose that the expression result of a if always returns true for the deployed test scenarios, and the effort to generate a false value is large.

In this case, you can put a breakpoint in the if line and change the value of the variables to force else .

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

For example:

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

In the example above, simply change the value of the variable entra to false in Eclipse, while keeping the breakpoint stopped at the if line, so you do not have the record inserted.

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

    
01.10.2014 / 15:50