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;
public abstract class ExternalFilter implements Filter {
/** The logger. */
- private static final Logger logger = Logger.getLogger(ExternalFilter.class.getName());
+ private final Logger logger = Logger.getLogger(getClass().getName());
/** The format of the source. */
private Format format;
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
} catch (IOException ioe1) {
/* okay, just exit. */
}
- logger.finest("ExternalFilter: Reading stdout finished.");
+ logger.finest("Reading stdout finished.");
}
}).start();
new Thread(new Connection(source) {
*/
protected abstract Iterable<String> 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. */
- }
- }
-
}