From 586d3e099da15d25e8f023e19e5bb22fec360b3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 30 Aug 2019 11:13:06 +0200 Subject: [PATCH] Event thread must not interrupt itself when hard stopping same applies to StopWatcher thread --- .../sonar/application/process/ManagedProcessHandler.java | 9 +++++++-- .../java/org/sonar/application/SchedulerImplTest.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java index 861900dcc20..d9b6835418d 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java +++ b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java @@ -177,8 +177,13 @@ public class ManagedProcessHandler { } public void stopForcibly() { - eventWatcher.interrupt(); - stopWatcher.interrupt(); + Thread currentThread = Thread.currentThread(); + if (currentThread != eventWatcher) { + eventWatcher.interrupt(); + } + if (currentThread != stopWatcher) { + stopWatcher.interrupt(); + } if (process != null) { process.destroyForcibly(); waitForDown(); diff --git a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java index 1277d40ea5f..533e9abc932 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java @@ -63,7 +63,7 @@ import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_TYPE; public class SchedulerImplTest { @Rule - public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(300)); + public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60)); @Rule public ExpectedException expectedException = ExpectedException.none(); @Rule -- 2.39.5