Browse Source

Improve handling of some thread interruptions

tags/6.2-RC1
Simon Brandhof 7 years ago
parent
commit
966f777895

+ 2
- 1
server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java View File

@@ -68,7 +68,8 @@ class StreamGobbler extends Thread {
try {
gobbler.join();
} catch (InterruptedException ignored) {
// consider as finished
// consider as finished, restore the interrupted flag
Thread.currentThread().interrupt();
}
}
}

+ 1
- 1
server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java View File

@@ -135,7 +135,7 @@ public class ProcessEntryPoint implements Stoppable {
stopperThread.join();
lifecycle.tryToMoveTo(Lifecycle.State.STOPPED);
} catch (InterruptedException e) {
// nothing to do, the process is going to be exited
Thread.currentThread().interrupt();
}
exit.exit(0);
}

+ 2
- 0
server/sonar-process/src/main/java/org/sonar/process/StopWatcher.java View File

@@ -56,6 +56,8 @@ public class StopWatcher extends Thread {
Thread.sleep(delayMs);
} catch (InterruptedException ignored) {
watching = false;
// restore interrupted flag
Thread.currentThread().interrupt();
}
}
}

+ 5
- 4
server/sonar-search/src/main/java/org/sonar/search/SearchServer.java View File

@@ -66,12 +66,13 @@ public class SearchServer implements Monitored {

@Override
public void awaitStop() {
while (node != null && !node.isClosed()) {
try {
try {
while (node != null && !node.isClosed()) {
Thread.sleep(200L);
} catch (InterruptedException e) {
// Ignore
}
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
}
}


+ 2
- 1
sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java View File

@@ -147,7 +147,8 @@ public class CommandExecutor {
try {
thread.join();
} catch (InterruptedException e) {
LOG.error("InterruptedException while waiting finish of " + thread.toString(), e);
// considered as finished, restore the interrupted flag
Thread.currentThread().interrupt();
}
}
}

Loading…
Cancel
Save