From 8c8350df16db22fbd378339eed506429d48cd9b4 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 16 May 2019 10:30:18 -0400 Subject: [PATCH] Protect logged exec spooling from no output 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. --- .../minimumRuntime/org/elasticsearch/gradle/LoggedExec.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/minimumRuntime/org/elasticsearch/gradle/LoggedExec.java b/buildSrc/src/main/minimumRuntime/org/elasticsearch/gradle/LoggedExec.java index a3f8757293204..4cc48eb14ece4 100644 --- a/buildSrc/src/main/minimumRuntime/org/elasticsearch/gradle/LoggedExec.java +++ b/buildSrc/src/main/minimumRuntime/org/elasticsearch/gradle/LoggedExec.java @@ -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); }