aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process-monitor
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-11-14 16:06:23 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-11-16 10:09:21 +0100
commit7c6a909d760e457af4259bf49bfbc6e1902d631b (patch)
treea47402a814b5095d239ba4921b893c5e702d7560 /server/sonar-process-monitor
parentadf8fbe5364084c3da6d004d1ad55cba0620be4d (diff)
downloadsonarqube-7c6a909d760e457af4259bf49bfbc6e1902d631b.tar.gz
sonarqube-7c6a909d760e457af4259bf49bfbc6e1902d631b.zip
SONAR-8333 restore process name in logs
because when running ITs with option -Dsonar.log.console we can't make a difference between logs from each process anymore
Diffstat (limited to 'server/sonar-process-monitor')
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java
index 6020f255e36..52a43e170d1 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java
@@ -19,27 +19,26 @@
*/
package org.sonar.process.monitor;
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import javax.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Reads process output and writes to logs
*/
-class StreamGobbler extends Thread {
+public class StreamGobbler extends Thread {
+
+ public static final String LOGGER_GOBBLER = "gobbler";
private final InputStream is;
private final Logger logger;
StreamGobbler(InputStream is, String processKey) {
- this(is, processKey, LoggerFactory.getLogger("gobbler"));
+ this(is, processKey, LoggerFactory.getLogger(LOGGER_GOBBLER));
}
StreamGobbler(InputStream is, String processKey, Logger logger) {
@@ -50,16 +49,13 @@ class StreamGobbler extends Thread {
@Override
public void run() {
- BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
- try {
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
logger.info(line);
}
} catch (Exception ignored) {
// ignored
- } finally {
- IOUtils.closeQuietly(br);
}
}