Skip to content

Commit

Permalink
#36 Log exception when unable to read from underlying stream
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiranda committed Oct 21, 2014
1 parent 814ea7b commit aef7042
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/jcabi/log/VerboseProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ public Void call() throws Exception {
writer.write(line);
writer.newLine();
}
} catch (final IOException ex) {
Logger.error(
VerboseProcess.class,
"Error reading from process stream: %[exception]s",
ex
);
} finally {
VerboseProcess.close(writer);
this.done.countDown();
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/jcabi/log/VerboseProcessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void stdoutQuietlyLogsErrors() throws Exception {
/**
* VerboseProcess exits "gracefully" when it can't read from the process
* stream, and logs the error that is thrown.
* @throws Exception
* @throws Exception If something goes wrong
*/
@Test
public void logsErrorWhenUnderlyingStreamIsClosed() throws Exception {
Expand All @@ -231,9 +231,7 @@ public void logsErrorWhenUnderlyingStreamIsClosed() throws Exception {
new VerboseProcess(prc, Level.ALL, Level.ALL).stdout();
MatcherAssert.assertThat(
writer.toString(),
Matchers.containsString("underlying process stream was closed")
Matchers.containsString("Error reading from process stream")
);
}

}
;

0 comments on commit aef7042

Please sign in to comment.