From 3785d6d2a32e9aa977eff5a8d8dfca4ddce43333 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Mar 2013 12:26:29 +0100 Subject: [PATCH] Use input stream drainer. --- .../sonitus/data/filter/ExternalFilter.java | 27 ++-------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java index 9242166..c2f6715 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java @@ -31,6 +31,7 @@ import net.pterodactylus.sonitus.data.Connection; import net.pterodactylus.sonitus.data.Filter; import net.pterodactylus.sonitus.data.Format; import net.pterodactylus.sonitus.data.Source; +import net.pterodactylus.sonitus.io.InputStreamDrainer; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -81,18 +82,7 @@ public abstract class ExternalFilter implements Filter { final InputStream processError = process.getErrorStream(); final PipedOutputStream pipedOutputStream = new PipedOutputStream(); pipedInputStream = new PipedInputStream(pipedOutputStream); - new Thread(new Runnable() { - - @Override - public void run() { - try { - drainInputStream(processError); - } catch (IOException ioe1) { - /* ignore, just let the thread exit. */ - } - logger.finest("ExternalFilter: Reading stderr finished."); - } - }).start(); + new Thread(new InputStreamDrainer(processError)).start(); new Thread(new Runnable() { @Override @@ -152,17 +142,4 @@ public abstract class ExternalFilter implements Filter { */ protected abstract Iterable parameters(Format format); - // - // STATIC METHODS - // - - private static void drainInputStream(InputStream inputStream) throws IOException { - byte[] buffer = new byte[4096]; - int read; - while ((read = inputStream.read(buffer)) != -1) { - logger.finest(String.format("ExternalFilter: Drained %d Bytes.", read)); - /* do nothing, just read the damn thing. */ - } - } - } -- 2.7.4