diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-01-08 15:51:06 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-01-13 13:42:43 +0100 |
commit | 255e54d582d02ab72d1b33f440656fb2d5ae9f8c (patch) | |
tree | 57c23abb47875009240b3e442801b58d8c3237ab /server/sonar-process-monitor | |
parent | 1d49769ae87ac8a2a553815bf2bfc9bf17a85f8f (diff) | |
download | sonarqube-255e54d582d02ab72d1b33f440656fb2d5ae9f8c.tar.gz sonarqube-255e54d582d02ab72d1b33f440656fb2d5ae9f8c.zip |
SONAR-7168 fix stop failing during restart + restart WS call flood issue
stop triggered though shareMemory by Orchestrator did not work when a restart was under way be lifeCycle transition from RESTARTING to STOPPING wasn't allowed
when flooding the restart WS, the restart never occured because the WS erased the shareMemory space of the WebServer when called called, erasing the stop signal sent by the main process
Diffstat (limited to 'server/sonar-process-monitor')
-rw-r--r-- | server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java index 98498c0e17e..749389d1054 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java @@ -188,15 +188,16 @@ public class Monitor { private void cleanAfterTermination() { trace("go to STOPPED..."); // safeguard if TerminatorThread is buggy and stop restartWatcher - lifecycle.tryToMoveTo(State.STOPPED); - trace("await termination of restartWatcher..."); - // wait for restartWatcher to cleanly stop - awaitTermination(restartWatcher); - trace("restartWatcher done"); - // removing shutdown hook to avoid called stop() unnecessarily unless already in shutdownHook - if (!systemExit.isInShutdownHook()) { - trace("removing shutdown hook..."); - Runtime.getRuntime().removeShutdownHook(shutdownHook); + if (lifecycle.tryToMoveTo(State.STOPPED)) { + trace("await termination of restartWatcher..."); + // wait for restartWatcher to cleanly stop + awaitTermination(restartWatcher); + trace("restartWatcher done"); + // removing shutdown hook to avoid called stop() unnecessarily unless already in shutdownHook + if (!systemExit.isInShutdownHook()) { + trace("removing shutdown hook..."); + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } } } @@ -288,7 +289,7 @@ public class Monitor { } private void stopProcesses() { - ArrayList<WatcherThread> watcherThreads = new ArrayList<>(this.watcherThreads); + List<WatcherThread> watcherThreads = new ArrayList<>(this.watcherThreads); // create a copy and reverse it to terminate in reverse order of startup (dependency order) Collections.reverse(watcherThreads); |