This article is participating in “Java Theme Month – Java Debug Notes Event”, see < Event link > for more details.

preface

  • I wonder how many times local development didn’t have a problem. The line just doesn’t work
  • I don’t know how you deal with these scenarios. Today we have Foley to be exact, idea is coming with Foley

Problem description

  • One night when we were going online, the test feedback said that a certain business was abnormal. Then we tried to debug the same data configuration and the same operation. We made breakpoints for many times and found no abnormality
  • While I was still struggling, my tech manager came up to me and said why don’t you use remote debugging tool of IDEA?
  • Then, the Baidu search page for remote debugging of IDEA was launched

Idea Remote debugging

  • The debugging configuration mode is mainly to set JVM parameters to work in debug mode. The common parameters are as follows:

If the project is a Web project, add the following information to the Tomcat startup program, such as Catalina. sh:

If the project is a JavaApp project, add the following to the default file of the project:

  • The idea of configuration

Open run/ Debug Configurations in idea, select the remote type, set the address to the server address, and set the port to address in the above configuration parameters.

  • With that done, we still have one more step to enjoy. Since we’re debugging remotely, we have to make sure that the local code is exactly the same as the code in the environment we’re debugging.
  • Normally we just reload the bag. Interrupt point debugging is then performed locally via the newly opened port with idea

defects

  • Online is, in principle, tightly controlled. Open a port for developers to debug at will for developers is convenient. But the maintenance of the site is a disaster. Because the opening of ports may give hackers an opportunity to attack
  • Other functions may be in use during the launch period. The Internet is basically grayscale publishing and if I debug it randomly it blocks the whole thing. So it affects the use
  • The other problem is the developer, who can cause dirty data on the line if the developer executes the code multiple times during debugging

conclusion

  • There are always two sides to everything. First, remote debugging is for the convenience of developers.
  • The convenience also brings other problems. We need to weigh the pros and cons of using this tool

Thumb up,