Skip to content

Commit

Permalink
Protect logged exec spooling from no output (#42177)
Browse files Browse the repository at this point in the history
This commit adds a guard around reading the spooled LoggedExec output.
It is possible the exec command did not output anything, and failed,
which would trigger a failure to read the output file.
  • Loading branch information
rjernst authored May 16, 2019
1 parent 41739a1 commit 4496794
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public void setSpoolOutput(boolean spoolOutput) {
out = new LazyFileOutputStream(spoolFile);
outputLogger = logger -> {
try {
Files.lines(spoolFile.toPath()).forEach(logger::error);
// the file may not exist if the command never output anything
if (Files.exists(spoolFile.toPath())) {
Files.lines(spoolFile.toPath()).forEach(logger::error);
}
} catch (IOException e) {
throw new RuntimeException("could not log", e);
}
Expand Down

0 comments on commit 4496794

Please sign in to comment.