diff options
Diffstat (limited to 'server/sonar-process-monitor')
-rw-r--r-- | server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java | 20 |
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); } } |