@Test(expected = TaskException.class) public void testIoExceptionThrown() { InputStream mockStream = new InputStream() { @Override public int read() throws IOException { throw new IOException("oops"); } }; StreamLogger logger = new StreamLogger(mockStream, new SystemStreamLog()); logger.run(); }
@Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); @Override void run(); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); @Override void run();  }