Skip to content

Commit

Permalink
Call exitValue only if process completed
Browse files Browse the repository at this point in the history
Otherwise this will throw an exception, making the check for completion
irrelevant and possibly leaving a dangling process.
  • Loading branch information
hinerm committed Feb 6, 2025
1 parent 819ffef commit 6fe428c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ private static List<String> collectProcessOutput(Process p)
throws IOException, InterruptedException
{
boolean completed = p.waitFor(5, TimeUnit.SECONDS);
p.exitValue();
if (!completed) {
p.destroyForcibly();
throw new IOException("Process took too long to complete.");
}
p.exitValue();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
return reader.lines().collect(Collectors.toList());
}
Expand Down

0 comments on commit 6fe428c

Please sign in to comment.