Protect logged exec spooling from no output (#42177)
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.
This commit is contained in:
parent
c40bd31073
commit
a6e63e6fa8
|
@ -63,7 +63,10 @@ public class LoggedExec extends Exec {
|
||||||
out = new LazyFileOutputStream(spoolFile);
|
out = new LazyFileOutputStream(spoolFile);
|
||||||
outputLogger = logger -> {
|
outputLogger = logger -> {
|
||||||
try {
|
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) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("could not log", e);
|
throw new RuntimeException("could not log", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue