The restart of the SMS gateway was modified last week.ProgramAs a result, a new problem was encountered this week. Although the instance can be restarted successfully, the instance may fail to be restarted. I did not find this problem during the local simulation test. I analyzed the logs in the official environment, the cause of unsuccessful restart is that the program does not automatically restart because the system does not receive a response message three times after the heartbeat, but continuously sends a heartbeat.
LookCodeNo error found. I thought, is it because of recursive call of methods? So I made a simple test to verify:
Public Static BooleanTests (IntI ){If(I> 5){Return False;}If(True) {Tests (++I );}Return True;}
This is really a problem. It turns out that after the tests () method calls the tests () method, each test () method has its own return value, only the tests () method at the first layer outputs its own return value to the program that calls it.
For example, if a program calls tests (1), tests (2) returns the returned value to tests (1), tests (3) return the returned value to test (2), and so on. After tests (5) is run, tests (1) is executed downward, and the final result is true in any case.
Therefore, if the result here is correct, set a flag to receive the value returned by each tests () method.
Public static Boolean tests (int I) {Boolean flag = false; if (I> 5) {return false;} If (true) {flag = tests (++ I );} return flag ;}
In this way, you can get the desired result.
Warning: traps for recursive call of return values